Excel: #NA error while using index and match - excel

I'm working with excel 2016. I am trying to use INDEX and MATCH to insert numbers into the ALT COST/ACRE. the screenshot is the first table.
I'm trying to insert ZIP AVG PRICE/ACRE from table 2, which looks like:
into ALT COST/ACRE
my attempt , as you can see in the first screenshot is :
=INDEX(Table2[[zip avg price/acre]:[ZIP2]],MATCH([#ZIP],Table2[[#Headers],[ZIP2]],0),1)
However this results in a
#NA
error. How can I fix this?

Table2[[#Headers],[ZIP2]] represents the single header cell that contains the column name, ZIP2.
As you want to search for [#ZIP] in the entire column ZIP2 rather than in its header cell, you should replace it with Table2[ZIP2] which is the data portion of the ZIP2 column:
=INDEX(Table2[[zip avg price/acre]:[ZIP2]], MATCH([#ZIP],Table2[ZIP2],0), 1)
Then you could note that the INDEX is not using the second column out of the Table2[[zip avg price/acre]:[ZIP2]], at which point it would become:
=INDEX(Table2[zip avg price/acre], MATCH([#ZIP],Table2[ZIP2],0), 1)

Related

Percentage Over Column Total Calculation

I am trying to do a cross table with a column that calculates the percentage the column total (third column from the left). I've been trying to follow some examples found in my Google searches but can't seem to get it to work.
I tried to insert this custom expression in my subsets:
Count() THEN [Value] / Sum([Value]) OVER (All([Axis.Rows]))
But I get this error: The expression is not valid after 'THEN' on line 1 character 9.
If someone still trying to do this you can do this :
Count() then Sum([Value]) Over (AllPrevious([Axis.Rows])) / Sum([Value]) OVER (All([Axis.Rows])) as [Cumulative Sum]
That will give you this result :
Where you have "(Column Names)" in Horizontal, [country] in Vertical axis and the sum and cumulative sum in the Cell Values.

Excel power query average of all values in a column

I have a table in power query and I want to create a new column that displays the average of all values of another referenced column. Any idea how to achieve this? So for example the home.goaldFor column i want to add-up all values and devide by the number of values.
i have tried multiple ways, including this one:
Avg = List.Average(
Table.SelectColumns(
#"ENG - Premier League",
[home.goalsFor],
0
)
)
But that's giving me the error:
Expression.Error: A cyclic reference was encountered during evaluation.
Anyone any ideas ?
I suspect that #"ENG - Premier League" the name of the current step based on the error you're getting.
Try this instead:
Avg = List.Average(#"Previous Step Name"[home.goalsFor])

Index Match - REF error but formula looks correct?

I've got two sheets and I'm trying to use Index Match to fill a summary table.
It looks up the name in summary table and fills a number of columns. I've checked the formula but it's giving me a REF error (note- I've counted the rows and columns and these are correct) - using the excel function tool it also shows its picking up the correct row.
My Formula :
=INDEX('Deal Return Detail'!AA5:AQ24,MATCH('Portfolio Summary - Graphs'!B27,'Deal Return Detail'!F:F,0),MATCH(G26,'Deal Return Detail'!2:2,0))
Deal return Detail is the sheet with values
Portfolio summary is the summary sheet
Welcome any help as I've checked on here and a number of index match tutorials but no luck as it seems to be a correct formula.
thanks,
L
Disclaimer : I'm just expanding #Rory comments since the OP didn't get the gist..
In index(a,b,c) function. the dimension of 'a' should match the row height of 'b' and the column width of 'c'.
So let sat 'a' is a 20 column by 50 rows data/range, the 'b' should be a 50 rows match/list and 'c' should be a 20 rows match/list.
in your case.. something like :
=INDEX('Deal Return Detail'!AA5:AQ24,MATCH(G26,'Deal Return Detail'!A2:Q2,0),MATCH('Portfolio Summary - Graphs'!B27,'Deal Return Detail'!F5:F24,0))
should do. Hope it explains.. ( :

Using tbl.Lookup to match just part of a column value

This question relates to the Schematiq add-in for Microsoft Excel.
Using =tbl.Lookup(table, columnsToSearch, valuesToFind, resultColumn, [defaultValue]) the values in the valuesToFind column have a consistent 3 characters to the left and then varying characters after (e.g. 908-123456 or 908-321654 - i.e. 908 is always consistent)
How can I tell the function to lookup the value based on the first 3 characters only? The expected answer should be the sum of the results of the above, i.e. 500 + 300 = 800
tbl.Lookup() works by looking for an exact match - this helps ensure it's fast but in this case it means you need an extra step to calculate a column of lookup values, something like this:
A2: =tbl.CalculateColumn(A1, "code", "x => LEFT(x, 3)", "startOfCode")
This will give you a new column that you can use for the columnsToSearch argument, however tbl.Lookup() also looks for just one match - it doesn't know how to combine values together if there is more than one matching row in the table, so I think you also need one more step to group your table by the first 3 chars of the code, like this:
A3: =tbl.Group(A2, "startOfCode", "amount")
Because tbl.Group() adds values together by default, this will give you a table with a row for each distinct value of startOfCode and the subtotal of amount for each of those values. Finally, you can do the lookup exactly as you requested, which for your input table will return 800:
A4: =tbl.Lookup(A3, "startOfCode", "908", "amount")

Finding the next result from a MATCH

I am trying to produce a sorted table in excel, which depend on the selected year and category.
My methodology has been to sequentially find largest values in order, within the selected year and category parameters, doing the following:
Column E
{=LARGE(IF(('Master Data'!A$1:A$500 = $B$1) * ('Master Data'!B$1:B$500 = $B$2),'Master Data'!C$1:C$500), $B10)}
This works fine, $B$1$ is where I store the year, $B$2 is where I store the category, $B10 references a hard coded 1-25 in column B.
Column F
{=MATCH(E10,IF(('Master Data'!A$1:A$500 = $B$1) * ('Master Data'!B$1:B$500 = $B$2),'Master Data'!C$1:C$500),FALSE)}
This returns the row number of the result I need, which I then use in conjunction with INDEX to find related data.
The problem with this is that Match only returns the first row number, and if you have two results with the same value this clearly becomes an issue.
Column G
To resolve this I used an example from dailydoseofexcel which looks like this:
=IF(F10<>F11, F11, G10+MATCH(E11,INDIRECT("'Master Data'!C"&(G10+1)&":C500"),0))
This works to a limited extent, for my purposes, as it is unable to take into account the year and category filter I need to apply, so I tried:
{=IF(F10<>F11, F11, G10+MATCH(E11,IF((INDIRECT("'Master Data'!A"&(G10+1)&":A500") = $C$2) * (INDIRECT("'Master Data'!B"&(G10+1)&":B500") = $C$3), INDIRECT("'Master Data'!C"&(G10+1)&":C500")),0))}
But I am just getting #N/A as a result.
I think SUMPRODUCT may be what you are looking for:
Charley Kyd XL Legend: Use SUMPRODUCT to get the Last item in a list

Resources