Forum Discussion

krountree's avatar
krountree
Copper Contributor
Aug 02, 2021

Averaging across multiple tables with various criteria

Hello,

 

I'm looking for help on two problems right now that are intertwined.

 

First, I have data for many devices stored in a single sheet called "Summary". The data are imported into their respective tables in the Summary sheet based upon the device number. So if I have 20 different devices, I have 20 different tables on the Summary tab and each table is listed as TableDeviceNumber (e.g., if device number is 101, the table name is Table101). Each device is categorized by whether it underwent test1 or test2 (this is written once in column B under the "Description" header). Then, every 1,000 hours, data is imported into the LFM rows (column D). 

What I want to be able to do is to average the values in the LFM column for any device labeled as going through test1 at 0 hrs, 1,000 hrs, 2,000 hrs,..., etc. The same calculations would be performed on the test2 devices. An example calculation is on the Calculations tab (obviously hard coded). 

I've tried sumproduct but there are a couple problems. First, I have to hard code in the Table numbers which is problematic when there are 30-40 tables. To circumvent the hard coding of table numbers, I tried to use the indirect function (which you can see works in columns m and n of this example sheet) but for some reason with my real data, it always gives me a reference invalid answer with the same exact formula. I can see that the table is there. I don't understand the error. Is there a way around using the indirect function to get what I want or a possible reason that it would show up? 


1 Reply

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    krountree 

    Power Query will be easier solution if you consider such option. Let assume you have few dozens of tables having same structure and names are from "Table..".

     

    You may query Excel.CurrentWorkbook(), select all names begins from "Table", fill down the tests and pivot result.

    With new data that's only refresh.

     

Resources