Forum Discussion
neny2000
Feb 09, 2023Copper Contributor
Why does this Index Match Work
INDEX('last week sales'!U:U,MATCH(1,('last week sales'!W:W=LARGE('last week sales'!W:W,B128))*(COUNTIF($C$127:C127,'last week sales'!U:U)=0),0)) Where U is a list of products and W is the sales f...
mtarler
Feb 10, 2023Silver Contributor
so I see mathetes already replied but I think I can add to this (I've had it open in a tab to "get to" and hadn't until now).
So 2 things: a) I will break down the formula for you so you can learn but b) if you have new version of excel (like 365) then you should consider some of those new functions.
INDEX('last week sales'!U:U,
MATCH(1,
('last week sales'!W:W=LARGE('last week sales'!W:W,B128))
*(COUNTIF($C$127:C127,'last week sales'!U:U)=0)
,0))
so the formula is chopped into lines above
1st line is just the column you want to index
2nd line is that you want to match 1 to some array of conditions
3rd line is comparing every value in W to the Nth largest value in W (i.e. each line that is that Nth largest will be a 1 and all others will be 0)
4th line is performing a UNIQUE function and giving a 1 for each value that is unique and 0 for values that match prior given results
5th line closes the match with setting it for exact match and closes index
So by mutlipling the 3rd and 4th lines is like an AND operation so it will show the Nth largest value on the Nth line and will 'skip' that line if the Nth largest value was already in the list above that line. That said I think you could use COUNTIF(C127 instead of COUNTIF($C$127:C127 because you only care if it is a repeat of the one immediately before and not a repeat of any item before. Slightly more efficient.
Hope that helps
That all said you can now use UNIQUE(SORT('last week sales'!U:U)) to get a unique sorted ranked list but if I analyzed your formula right it will look slightly different in that it will be a list with no gaps.
So 2 things: a) I will break down the formula for you so you can learn but b) if you have new version of excel (like 365) then you should consider some of those new functions.
INDEX('last week sales'!U:U,
MATCH(1,
('last week sales'!W:W=LARGE('last week sales'!W:W,B128))
*(COUNTIF($C$127:C127,'last week sales'!U:U)=0)
,0))
so the formula is chopped into lines above
1st line is just the column you want to index
2nd line is that you want to match 1 to some array of conditions
3rd line is comparing every value in W to the Nth largest value in W (i.e. each line that is that Nth largest will be a 1 and all others will be 0)
4th line is performing a UNIQUE function and giving a 1 for each value that is unique and 0 for values that match prior given results
5th line closes the match with setting it for exact match and closes index
So by mutlipling the 3rd and 4th lines is like an AND operation so it will show the Nth largest value on the Nth line and will 'skip' that line if the Nth largest value was already in the list above that line. That said I think you could use COUNTIF(C127 instead of COUNTIF($C$127:C127 because you only care if it is a repeat of the one immediately before and not a repeat of any item before. Slightly more efficient.
Hope that helps
That all said you can now use UNIQUE(SORT('last week sales'!U:U)) to get a unique sorted ranked list but if I analyzed your formula right it will look slightly different in that it will be a list with no gaps.