I'm using following dynamic table reference several times in my workbook which is causing performance issues:
SUMIFS(INDIRECT(VLOOKUP($A$1,$A$2:$B$4,2,0)&"[kpi_name]"),INDIRECT(VLOOKUP($A$1,$A$2:$B$4,2,0)&"[filter1]"),UPPER($H13))
based on the input in A1 I need to switch between table1, table2 and table3.
I do this by building a vlookup map in A2:B4 that return the appropiate table names and using this + column name in a indirect formula.
I would like to move to a better solution using INDEX or another named range.
I tried to use a named range with a formula returning the right table reference:
=IF(A1=1,table1,IF(A1=2,table2,IF(A1=3,table3,0)))
But this way I can't use named_range[column of table]
Also I can't get a working solution with INDEX...
Thanks to the comments of the initial question I came up with follow:
SUMIFS(INDEX(CHOOSE(A1,TABLE1,TABLE2),,MATCH(VAR_COLUMN_NAME,INDEX(CHOOSE(A1,TABLE1,TABLE2),1,0),0)),INDEX(CHOOSE(A1,TABLE1,TABLE2),,MATCH("filter1",INDEX(CHOOSE(A1,TABLE1,TABLE2),1,0),0)),UPPER(ABC))
Related
I am summarizing data from a table in another workbook using sth like
COUNTIFS(filename.xlsm!Sheet[DataReference];">=1/1/2021";filename.xlsm!Sheet[DataReference];"<=31/3/2021")
I have create these formulas for 16 quarters and am using the same formula for many data references. To avoid errors (and trying to save manually editing the data reference in every cell twice), I would like to have a field in my row that holds the value for "DataReference" and use that as a variable inside the reference. This way I can copy&paste the formula in many rows and only need to plug in the right data reference and avoid further errors/inconsistencies.
But neither by googling nor by trial and error have I found a way for Excel to accept a variable inside the brackets
I found it! I need to use INDIRECT and build the path:
COUNTIF(INDIRECT(<cellwithfilename>&"!"&<Cell with worksheet name>&"["&<cell with data range>&"]"; ....
I'm trying to find the code for the best match in a table using 4 lookup values.
In the image below the left table A to E is a static table and is the reference table
The right table normally on a separate sheet has multiple lines of varying data, where I need to find the correct code based matching the Name, Age and Age Calc from, using the information in the reference table.
I have tried VLOOKUP and INDEX/MATCH, but I'm struggling with the multiple lookup values.
The answers I need in J are: 5678, 7654, 4679, 7654, 1234.
What would be my best method of achieving my code results?
You can do this with a SUMIFS:
=SUMIFS(E:E,A:A,G2,B:B,"<="&H2,C:C,">="&H2,D:D,I2)
Assuming there can be only one match, then do something like:
=SUMIFS($E$2:$E$6,$A$2:$A$6,G2,$B$2:$B$6,"<="&H2,$C$2:$C$6,">="&H2,$D$2:$D$6,I2)
This is the formula that worked for me.
=INDEX(E:E,AGGREGATE(15,6,ROW(E$2:E$6)/(A$2:A$6=G2)/(B$2:B$6<=H2)/(C$2:C$6>=H2)/(D$2:D$6=I2),1))
I have an Excel workbook that contains 12 named ranges for each month of the year (JanuaryTallies, FebruaryTallies), each containing two columns, Amount and Category.
What I am trying to do is get the sum of all the "Amounts" which pertain to each "Category" for the current month. For example, given that it's currently May, I would like to be able to get the SUM() of all the values in the Amount column in the MayTallies named range, that have the value "Groceries" in the adjacent Category cell.
I know that I can get the name of the current month by using =TEXT(TODAY(), "mmmm") and generate the relevant range name using =(TEXT(TODAY(), "mmmm") & "Tallies").
I also know that if these were individual tables rather than named ranges I could do use something like SUMIFS(MayTallies[Amount], MayTallies[Category], "Groceries"), but not only does this not seem to work with named ranges, I'm having trouble actually generating the named range within the formula dynamically.
Logically, I'm looking to be able to do something like:
SUMIFS(
(TEXT(TODAY(), "mmmm") & "Tallies")[Amount],
(TEXT(TODAY(), "mmmm") & "Tallies")[Category],
"Groceries" )
Could anyone point me in the direction on how to achieve this? Even some thoughts on both generating a named range reference with dynamic concatenation and some alternative to SUMIFS that uses named ranges would be helpful. Thanks.
EDIT: Update!
I have solved part of the problem by making these named ranges tables instead. This allows me to use SUMIFS(). Now I just need to figure out how to dynamically generate the reference.
I was able to solve this problem in a partially roundabout way. I converted the named ranges into tables in order to allow for me to use SUMIFS() then used INDIRECT() as #BigBen recommended in the comments. The final formula was as follows:
=SUMIFS((INDIRECT((TEXT(TODAY(),"mmmm")&"Tallies")&"[Amount]")),
(INDIRECT((TEXT(TODAY(),"mmmm")&"Tallies")&"[Category]")),
"Groceries")
I have a table that I am using to summarize some data from other tables; the data is almost entirely text so a pivot table isn't the answer. I have a table on a worksheet as follows...
Here is a typical formula for columns D:L...
FORMULA: =INDEX(tblITPM,MATCH(tblHCSmry[[#Headers],[Data Source]],tblITPM[[#All],[Column1]],0),MATCH([#MetricName],'SheetA'!$A$2:$D$2,0))
Individally, the formulae seem to work fine but the total of the calculations only works in the first 3 rows of my summary table (tblHCSmry). There are two issues that I don't know how to solve:
In the "array" section of the INDEX I am referencing table
names that are listed in column B (TableName); hard-coding like I
have above (tblTableA) makes all of the items that need to reference
a separate table on a separate worksheet to fail.
The MATCH formula (MATCH([#MetricName],'1_ITPM_Summary'!$A2:$D2,0)) have a similar issue; I get the correct answer for the first 3 tables (2, 3, or 4) which I expect since the "lookup_array" is hard-coded. So, the issue again arises though when I want to reference a different table such as tblTableB by pointing to Column B of tblHCSmry.
I suppose the main question is: can I use a named range of a table, or do I need to use the "'SheetA'!A3:D3" format? If so, is there a way to dynamically change, "'SheetA'!" to "'SheetB'!" by referencing Column B of the tblHCSmry? FWIW: I tried to CONCATENATE the Sheet name with the reference and that didn't work.
You can use named ranges, but you'd need to have pointers to the location of the data in cells, which appears to be what you already have in Columns A and B. You can then reference those dynamically using using =INDIRECT(). =INDIRECT() allows you to take a value of a cell and use that as a reference as opposed to the reference being to the cell itself.
For instance
=INDEX(INDIRECT([#TableName]),MATCH(tblHCSmry[[#Headers],[Data Source]],tblITPM[[#All],[Column1]],0),MATCH([#MetricName],INDIRECT("'" & [#TabName] & "'!$A$2:$D$2"),0))
Would make your return array whatever is referenced in [#TableName], and your array parameter in your second MATCH function would be whatever is referenced in [#TabName]
MSDN has very basic documentation of INDIRECT() here, but there's quite a bit you can accomplish with it as far as creating more dynamic formulas.
I am new to using Excel formulas.
I have an Excel with alot of formulas like
=IFERROR(VLOOKUP(B9,Data[[#All],[Field Location]:[On Production Date]],4,0),"")
I understand IFERROR function and VLOOKUP function.
What makes trouble understanding is table array in VLOOKUP function which is
Data[[#All],[Field Location]:[On Production Date]]
What this table array represents and how can I create something like this?
These are structured references. You can read more at:
Using structured references with Excel tables
Structured references make it much easier and more intuitive to work
with table data when you are using formulas that reference a table–
either portions of a table or the entire table. They are especially
useful because table data ranges often change, and the cell references
for structured references adjust automatically. This minimizes the
need to rewrite formulas as rows and columns are added and deleted in
a table, or when external data is refreshed.
Data[[#All],[Field Location]:[On Production Date]]
is the equivalent of giving a range. $Field Location2:$On Production Date1000, ($A2:$B1000)
assuming there are 1000 rows in your table. Writing the formula in this way will automatically include any new rows added to your Data table.
Data[[#Header],[Field Location]] is equivalent to $Field Location1. Or $A$1.
In Excel, you can give names to certain ranges. Just mark an area, and then on the top left (below the menu), you can enter a name in a drop-down-box.
This name can then subsequently be used in referencing the range, like it is shown in your formula.
This is more intuitive than writing A2:G98, and even more, when you insert new rows into the range, then they will automatically be included.