+ Reply to Thread
Results 1 to 6 of 6

compare two tables and find average

  1. #1
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    compare two tables and find average

    Hi,

    I have two tables which consists of columns titled last name, first name, department and rank as shown below.

    Screenshot 2022-11-10 185217.png

    As you can see from table 1 and 2, they include names of people with their department and rank. Some names appear on both tables, some only once.

    What I would like to do is use the first name, last name and department from my result table to locate their rank from both tables and then find the average.

    If the person only exists in one table then take the rank from that table.

    For example, Alan John appears in both tables, so his average rank would be (10+9)/2 = 9.5.

    I have attached my workbook as well.

    Thank you
    Attached Files Attached Files

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: compare two tables and find average

    with Power Query

    Please Login or Register  to view this content.
    Last edited by sandy666; 11-10-2022 at 04:15 AM. Reason: code

  3. #3
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    Re: compare two tables and find average

    I'm not familiar with power query. where do I put the code?

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: compare two tables and find average

    if structure of your real source tables is the same like in your example
    Data - New Query - From Other Source - Blank Query
    it will open PQ Editor - Advanced Editor - paste copied code there

    but first you need to use Ctrl+T for each "Table" (make them Excel Tables)

    if structure is different you need create M-code yourself

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,384

    Re: compare two tables and find average

    For the whole table in 1 go, try this formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I also tried a much simpler formula with AVERAGEIFS and even without BYROW and LAMBDA,
    but that failed because I couldn't properly define the range parameters of the AVERAGEIFS.

    As soon as I referred to an array instead of a range (with exactly the same size and values), the AVERAGEIFS started to spill and calculate incorrectly.
    Attached Files Attached Files

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,851

    Re: compare two tables and find average

    Further to Sandy's directions.

    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Compare two tables, find matches, and extract rows based on matches.
    By arcticspace in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-21-2022, 06:35 AM
  2. Replies: 3
    Last Post: 02-06-2020, 04:37 PM
  3. [SOLVED] Compare of 2 tables & find the differences
    By Regina HR in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-20-2020, 06:49 AM
  4. Compare two tables and find records without matches
    By Isaacliu in forum Access Tables & Databases
    Replies: 1
    Last Post: 11-14-2019, 11:01 PM
  5. Compare two tables and find only unmatching/remaining data
    By Isaacliu in forum Access Tables & Databases
    Replies: 4
    Last Post: 12-08-2016, 12:51 PM
  6. Replies: 2
    Last Post: 07-18-2015, 05:19 PM
  7. [SOLVED] Compare 2 Tables to find the PROFIT faster
    By harimin in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-28-2013, 06:55 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1