Combine COUNTIF formulas - excel

I need to select cels starts with this format (patern) "???. * Nr.?? CO*", and i write formula:
=IF(COUNTIF(A2;"<>???. * Nr.?? CO*");"NO";"OK")
In this selection i want to filter only cells starts wit "Pro.", "Ext." and "Fun.", and i write second formula:
=IF(SUM(COUNTIF(A2;{"Pro. *";"Ext. *";"Fun. *"}))=0;"NO";"OK")
Then i combine this both formulas in one single good formula:
=IF(OR(COUNTIF(A2;"<>???. * Nr.?? CO*");SUM(COUNTIF(A2;{"Pro. *";"Ext. *";"Fun. *"}))=0;);"NO";"OK")
And its working very well, but...
How is possible to combine both formulas without OR function? or
Exist some alternatives for this result?

Not entirely clear to me, but did you mean:
=IF(SUM(COUNTIF(A2,{"Pro","Ext","Fun"}&". * Nr.?? CO*")),"OK","NO")

Related

Excel formula to allow me to retrieve the codes of the most valuables drinks

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)
)

switch function Excel

I am working on an Excel switch funciton but something is not working.
I have 2 tables. This is my table 1 -
And this is my Table 2 -
Now, what is want is - when the table 1 "Pick value" Column has a value of A it should enter code herepick the value from Table 2 column value A Value when the value is B, it should pick B Value, else C value from the corresponding field.
That IS WHY I am using this switch query in Excel -
=SWITCH([Pick Value];"A";Table2[A Value];"B";Table2[B Value];Table2[C Value];)
But it is not working -
Anyone knows what I am doing wrong here!
Here is a SWITCH version also using XLOOKUP:
=XLOOKUP([#ID];Table2[ID];SWITCH([#[Pick Value]];"A";Table2[A Value];"B";Table2[B Value];"C";Table2[C Value]))
Use FILTER:
=#FILTER(CHOOSE(MATCH([#Pick Value];{"A";"B";"C"};0);Table2[A Value];Table2[B Value];Table2[C Value]);Table2[ID]=[#ID])
INDEX/MATCH
If you don't have 365, you can use one of the following formulas.
Comma
Array formula (CRTL+SHIFT+ENTER):
=IFERROR(INDEX(Table2[#[A Value]:[C Value]],MATCH([#[Pick Value]],LEFT(Table2[[#Headers],[A Value]:[C Value]],1),0)),"")
or if using "A","B","C" explicitly (ENTER):
=IFERROR(INDEX(Table2[#[A Value]:[C Value]],MATCH([#[Pick Value]],{"A","B","C"},0)),"")
Semi Colon
Array formula (CRTL+SHIFT+ENTER):
=IFERROR(INDEX(Table2[#[A Value]:[C Value]];MATCH([#[Pick Value]];LEFT(Table2[[#Headers];[A Value]:[C Value]];1);0));"")
or if using "A","B","C" explicitly (ENTER):
=IFERROR(INDEX(Table2[#[A Value]:[C Value]];MATCH([#[Pick Value]];{"A";"B";"C"};0));"")

Excel If statement needs to show blanks while being nested

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.

Excel AVERAGEIFS looking up ONE of the criteria columns

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.

Repetition of nested IF statements

I'm struggling to get an Excel query to work. I'm trying to have multiple queries like this within a query and am not sure how to work it. The query so far is this:
=IF(B6=$R$2,B2*$S$2,IF($B$6=$R$3,B2*$S$3,IF(B6=$R$4,B2*$S$4,B2)))
Here is what I'm trying to do, there are the 7 multipliers below, the above statement is for only one of them.
The logic is, that if the cell says Good it is multiplied by 97.5%, if Bad by 102.5%, if OK it's multiplied by 100%, but I need the odds to be multiplied by all 7 areas beneath. So its essentially an if/else statement 7 times within itself:
If B6 = Good * S2, else * S4, then if B7 = Good * S2, else S4, essentially that repeated 7 times down.
How can I do this in Excel?
In B2 and copied down:
=B2*LOOKUP(B6,{"Bad","Good","OK"},{1.025,0.975,1})
might suit but would still require entries into E2 etc.
Might not be as easy to understand but should give the same results (for the three conditions) and is a little shorter:
=B2*(1+.025*((B6="Bad")-(B6="Good")))
It would be better to use VLOOKUP as follows :
=B2 * VLOOKUP(B6,$R$2:$S$4,2) * VLOOKUP(B7,$R$2:$S$4,2) *
VLOOKUP(B8,$R$2:$S$4,2) * VLOOKUP(B9,$R$2:$S$4,2) *
VLOOKUP(B10,$R$2:$S$4,2) * VLOOKUP(B11,$R$2:$S$4,2) *
VLOOKUP(B12,$R$2:$S$4,2)
You could develop a simple User Defined function through VBA though. It would be better and more efficient.

Resources