Good night,
I'm trying to think of a simple excel formula to allow me to get the codes of the most valuables drinks.
I don't wanna use PivotTable for this one.
Ex:
I want to retrieve, for MALIBU, the code 8991
For JAMESON, the code 6113 etc
I'm stuck here since I woke up haha
Thanks!
Try below formula for dynamic spill result-
=LET(x,UNIQUE(C2:C12),y,BYROW(x,LAMBDA(r,INDEX(SORT(FILTER(A2:B12,C2:C12=r),2,-1),1,1))),HSTACK(x,y))
Using MAX function to consider the scenario where more than one code for a given drink can have the maximum value. In cell E2 use the following formula:
=LET(rng, A2:C13, codes, INDEX(rng,,1), values, INDEX(rng,,2),
drinks, INDEX(rng,,3), drinksUx, UNIQUE(drinks),
maxValues, BYROW(drinksUx, LAMBDA(ux,
TEXTJOIN(",",,FILTER(codes, (drinks = ux)
* (values = MAX(FILTER(values, drinks=ux))))))),
HSTACK(drinksUx, maxValues)
)
Here is the output:
Note: Another code for HEINEKEN was added for testing purpose of more than one code with maximum value.
XMATCH can be used for the same purpose too, but it is a more verbose formula:
=LET(rng, A2:C13, codes, INDEX(rng,,1), values, INDEX(rng,,2),
drinks, INDEX(rng,,3),drinksUx, UNIQUE(drinks),
maxValues, BYROW(drinksUx, LAMBDA(ux, TEXTJOIN(",",,
LET(maxValue, MAX(FILTER(values, drinks = ux)),
FILTER(codes, ISNUMBER(XMATCH(drinks & values, ux & maxValue))))))),
HSTACK(drinksUx, maxValues)
)
I am writing a formula to see cells that are blank along with see the cells that have a numeric value such as 0,10,-100 etc.
I have the following code that works but if the cell is blank it shows "0" and I need that to show blank. I should note that I am using offsets to make it easier to duplicate the data into other rows and just use REPLACE to speed up the process.
=IF(B1=DATEVALUE("7/3/2020"),OFFSET('CEDAR RAPIDS'!R4,0,0),
IF(B1=DATEVALUE("7/10/2020"),OFFSET('CEDAR RAPIDS'!R25,0,0),
IF(B1=DATEVALUE("7/17/2020"),OFFSET('CEDAR RAPIDS'!R47,0,0),
IF(B1=DATEVALUE("7/24/2020"),OFFSET('CEDAR RAPIDS'!R69,0,0),
IF(B1=DATEVALUE("7/31/2020"),OFFSET('CEDAR RAPIDS'!R91,0,0),
IF(B1=DATEVALUE("8/7/2020"),OFFSET('CEDAR RAPIDS'!R112,0,0),
IF(B1=DATEVALUE("8/14/2020"),OFFSET('CEDAR RAPIDS'!R133,0,0),
IF(B1=DATEVALUE("8/21/2020"),OFFSET('CEDAR RAPIDS'!R154,0,0),
IF(B1=DATEVALUE("8/28/2020"),OFFSET('CEDAR RAPIDS'!R174,0,0),
IF(B1=DATEVALUE("9/4/2020"),OFFSET('CEDAR RAPIDS'!R195,0,0),
IF(B1=DATEVALUE("9/11/2020"),OFFSET('CEDAR RAPIDS'!R215,0,0),
IF(B1=DATEVALUE("9/18/2020"),OFFSET('CEDAR RAPIDS'!R235,0,0),
IF(B1=DATEVALUE("9/25/2020"),OFFSET('CEDAR RAPIDS'!R255,0,0),
IF(B1=DATEVALUE("10/02/2020"),OFFSET('CEDAR RAPIDS'!R275,0,0),
IF(B1=DATEVALUE("10/9/2020"),OFFSET('CEDAR RAPIDS'!R295,0,0),
IF(B1=DATEVALUE("10/16/2020"),OFFSET('CEDAR RAPIDS'!R314,0,0),
IF(B1=DATEVALUE("10/23/2020"),OFFSET('CEDAR RAPIDS'!R334,0,0),
IF(B1=DATEVALUE("10/30/2020"),OFFSET('CEDAR RAPIDS'!R354,0,0),
IF(B1=DATEVALUE("11/6/2020"),OFFSET('CEDAR RAPIDS'!R374,0,0),
IF(B1=DATEVALUE("11/13/2020"),OFFSET('CEDAR RAPIDS'!R394,0,0),
IF(B1=DATEVALUE("11/20/2020"),OFFSET('CEDAR RAPIDS'!R414,0,0),
IF(B1=DATEVALUE("11/27/2020"),OFFSET('CEDAR RAPIDS'!R434,0,0),
IF(B1=DATEVALUE("12/4/2020"),OFFSET('CEDAR RAPIDS'!R454,0,0),
IF(B1=DATEVALUE("12/11/2020"),OFFSET('CEDAR RAPIDS'!R474,0,0)))))))))))))))))))))))))
I found this code below works correctly but I cannot seem to nest it like the above without errors.
=IF(B1=DATEVALUE("7/3/2020"),IF(ISBLANK('CEDAR RAPIDS'!F4),"",OFFSET('CEDAR RAPIDS'!F4,0,0)))
Format the result of the cells with a custom number format that suppresses zeroes, for example
0;-0;;#
By the way, if you want to check if the result of the OFFSET() is zero, then you need to check the result of the OFFSET(), not the anchor of the OFFSET().
There is bound to be a better formula for this scenario than this nested monster with Offset. Just ask.
I have built a large data set and I need to see the average results given many different criteria. I've done this with the AVERAGEIFS function and it works just fine, however the more and more I add its getting really time intensive.
I'm wondering if there is a way to nest a vlookup or index match or anything like that in the AVERAGEIFS that read the criteria column heading and criteria in a cell (or 2 if they need to be separated) to be added to the AVERAGEIFS.
Here is an example of my spreadsheet:
The first 3 sets of criteria I want to stay locked.
I want it to read what the 4th criteria column and criteria should be by referencing the I11 cell. The highlighted portion in the formula bar is the part that I want to reference I11 so it reads it and knows that the 4th criteria is the 'code' column and the criteria is '>7'. I can separate this into 2 separate cells if need be.
I've tried a few combinations of VLOOKUP and INDEX MATCH but cannot get it to work.
Data as Text:
Price,Type,sub cat,Time,code,amount,Result,,
,,,,,,,,
9.95,t2,d,ac,2.18," 22,780,893 ",0.73,,T2 and D and AC
118.94,u2,d,bo,2.78," 172,110,893 ",4.07,,
57.63,t1,u,ac,7.09," 128,419,877 ",-2.16,,code
8.88,t2,d,ac,1.50," 62,634,868 ",12.72,,amount < 100 000 000
11.61,u1,u,ac,2.14," 146,982,736 ",1.07,,price >10
13.46,u3,u,ac,0.93," 17,513,672 ",-13.93,,
31.53,t1,u,ac,0.89," 47,170,877 ",1.39,,
16.34,t3,d,bo,1.07," 1,914,767,076 ",-1.42,,
111.59,u1,d,bo,0.62," 2,283,546,000 ",0.67,,
72.4,u3,d,bo,10.37," 951,541,514 ",1.13,,
34.55,u3,d,bo,0.77," 951,541,514 ",-2.52,,
42.25,t1,d,bo,1.05," 63,748,352 ",8.88,,
17.18,u3,u,ac,2.64," 140,217,257 ",4.35,,
97.66,t1,d,bo,3.45," 1,070,383,954 ",1.33,,
58.49,t2,u,bo,8.64," 151,876,559 ",-0.92,,
64.48,t2,d,ac,2.35," 291,967,334 ",3.03,,
38.4,t1,u,ac,17.05," 83,478,472 ",-4.31,,
20.87,u3,d,ac,28.92," 214,080,937 ",-2.16,,
36.53,t1,d,ac,1.43," 73,438,589 ",-2.07,,
89.16,t3,u,ac,1.41," 26,786,958 ",-1.75,,
15.84,t1,u,bo,2.90," 133,560,818 ",1.76,,
3.2,u3,u,bo,2.95," 215,677,667 ",-1.06,,
25.46,t1,d,bo,3.92," 57,148,431 ",1.89,,
40,t2,d,ac,8.00," 65,274,903 ",0.61,,
27.72,t1,u,ac,2.50," 381,400,886 ",6.46,,
29.07,u3,u,ac,2.32," 52,632,107 ",-0.78,,
173.31,t1,d,ac,3.58," 31,547,380 ",-4.92,,
18.22,u3,d,ac,0.58," 292,669,493 ",4.06,,
9.59,t1,d,bo,3.60," 266,883,020 ",3.16,,
115.22,t2,d,bo,4.51," 132,376,476 ",0.78,,
64.48,u3,d,ac,3.03," 338,360,104 ",-0.95,,
41.74,t1,u,bo,25.65," 245,766,436 ",-3.42,,
5.99,t3,u,bo,2.15," 175,054,713 ",-4.37,,
Use INDEX/MATCH to return the correct column. This will require that you separate the column name and the criteria:
=AVERAGEIFS(G:G,B:B,"T2",C:C,"D",D:D,"AC",INDEX(A:F,0,MATCH(I11,$A$7:$G$7,0)),J11)
An idea:
I10 - "Write down the limitation. (You have to use <,>,=,<> AND the value, for e.g.: <5)"
I11 - The user can use relations and values.
In J11, you can reference to I11 ;) It works for me.