Using OR Logical functions with SUMIFS in Excel - excel
I have two workbooks in excel which I copy columns from one to the other.
I would like to copy the number of one column, say A, IF another column, say B, is equal to "Test Tool" or "Hard Tool". I've written this code and can't get it to work, it just gives me the sum zero which is wrong. The last argument doesn't matter so ignore it.
"=SUMIFS('Tooling forecast template'!R6C17:R500C17,'Tooling forecast template'!R6C7:R500C7,""OR(=Test Tool, =Hard Tool)"" ,'Tooling forecast template'!R6C6:R500C6,""<>Actual tool/equipment change"")"
Here is a method that saves you typing out a large number of SUMIF statements, although it doesn't stop Excel having to calculate the multiple SUMIFs...
=SUM( SUMIFS('Tooling forecast template'!R6C17:R500C17,'Tooling forecast template'!R6C7:R500C7, {"Test Tool", "Hard Tool"} ,'Tooling forecast template'!R6C6:R500C6,"<>Actual tool/equipment change") )
Basically, you calculate the SUMIF with an array of values as your criteria, then wrap that SUMIF in a SUM so that the multiple answers are added together.
This example is quite hard to read due to the long variable names. Here's a simpler example, where you want to add up some numbers where the corresponding letter is either A or B...
The long way:
=SUMIFS(B1:B5, A1:A5, "A") + SUMIFS(B1:B5, A1:A5, "B")
The short way:
=SUM( SUMIFS(B1:B5, A1:A5, {"A","B"}) )
=IF(OR(CellToCheck="Test Tool", CellToCheck="Hard Tool"), CellToCopy, 0)
Just add the two SUMIFS together, its the same thing!
=SUMIFS('Tooling forecast template'!R6C17:R500C17,'Tooling forecast template'!R6C7:R500C7,"=Test Tool" ,'Tooling forecast template'!R6C6:R500C6,"<>Actual tool/equipment change") + SUMIFS('Tooling forecast template'!R6C17:R500C17,'Tooling forecast template'!R6C7:R500C7,"=Hard Tool" ,'Tooling forecast template'!R6C6:R500C6,"<>Actual tool/equipment change")
Use the fact that A OR B is the same thing as NOT ((NOT A) and (NOT B)). For example, sum the entries in A if B=1 or C=1 using SUMIFS:
=SUM(A1:A10) - SUMIFS(A1:A10,B1:B10,"<>0",C1:C10,"<>0")
You can achieve the same result with SUMPRODUCT:
=SUM(A1:A10) - SUMPRODUCT(A1:A10,--(B1:B10<>0),--(C1:C10<>0))
Wouldn't this work as well?
Note:
Assuming Col A houses values to be summed.
Assuming Col B houses the tool types.
=SUM(SUMIFS(A:A,B:B,"hard tool"),SUMIFS(A:A,B:B,"test tool"))
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) )
Excel CUBEVALUE & CUBESET count records greater than a number
I am writing a series of queries to my workbook's data model to retrieve the number of documents by Category_Name which are greater than a certain numbers of days old (e.g. >=650). Currently this formula (entered in celll C3) returns the correct number for a single Days Old value (=3). =CUBEVALUE("ThisWorkbookDataModel", "[Measures].[Count of Docs]", "[EDD_Report].[Category_Name].&["&$B2&"]", "[EDD_Report_10-01-18].[Days Old].[34]") How do I return the number of documents for Days Old values >=650? The worksheet looks like: A B C 1 Date PL Count of Docs 2 10/1/2018 ALD 3 3 ... UPDATE: As suggested in #ama 's answer below, the expression in step B did not work. However, I created a subset of the Days Old values using =CUBESET("ThisWorkbookDataModel", "{[EDD_Report_10-01-18].[Days Old].[all].[650]:[EDD_Report_10-01-18].[Days Old].[All].[3647]}") The cell containing this cubeset is referenced as the third Member_expression of the original CUBEVALUE formula. The limitation is now that the values for the beginning and end must be members of the Days Old set. This is limiting, in that, I was hoping for a more general test for >=650 and there is no way to guarantee that specific values of Days Old will be in the query.
First time I hear about CUBE, so you got me curious and I did some digging. Definitely not an expert, but here is what I found: MDX language should allow you to provide value ranges in the form of {[Table].[Field].[All].[LowerBound]:[Table].[Field].[All].[UpperBound]}. A. Get the total number of entries: D3 =CUBEVALUE("ThisWorkbookDataModel", "[Measures].[Count of Docs]", "[EDD_Report].[Category_Name].&["&$B2&"]"), "{[EDD_Report_10-01-18].[Days Old].[All]") B. Get the number of entries less than 650: E3 =CUBEVALUE("ThisWorkbookDataModel", "[Measures].[Count of Docs]", "[EDD_Report].[Category_Name].&["&$B2&"]"), "{[EDD_Report_10-01-18].[Days Old].[All].[0]:[EDD_Report_10-01-18].[Days Old].[All].[649]}") Note I found something about using .[All].[650].lag(1)} but I think for it to work properly your data might need to be sorted? C. Substract C3 =D3-E3 Alternatively, go for the quick and dirty: =CUBEVALUE("ThisWorkbookDataModel", "[Measures].[Count of Docs]", "[EDD_Report].[Category_Name].&["&$B2&"]"), "{[EDD_Report_10-01-18].[Days Old].[All].[650]:[EDD_Report_10-01-18].[Days Old].[All].[99999]}") Hope this helps and do let me know, I am still curious!
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.
Any simple way to do VLOOKUP combine "linear interpolation" in excel?
I'm making an excel sheet for calculating z-score for infant weight/age (Input: "Baby Month Age", and "Baby weight"). To do that, I need get LMS parameters first for a specific month, from below table. http://www.who.int/childgrowth/standards/tab_wfa_boys_p_0_5.txt (For Integer Month number, this can be done by vlookup Method without issue.) For Non-Integer Month number, I need use some kind of "linear interpolation" approach to get an approximate LMS data. The question is, both Trend method and Vlookup method are not working for me. For Trend method, it is not working as the raw data, like L parameters is not linear data, if I use Trend method, for the several top month, return data will far from existing data. As for Vlookup method, it just finds the closest month data. I had to use multiple "Match" and "Index" Method to do the "linear interpolation" for myself. However, I wonder whether there is any existing function for that? My current formula for L parameters is below: =MOD([Month Age],1)*(INDEX('WHO BOY AGE WEIGHT'!A:D,MATCH([Month Age],'WHO BOY AGE WEIGHT'!A:A)+1,2)-INDEX('WHO BOY AGE WEIGHT'!A:D,MATCH([Month Age],'WHO BOY AGE WEIGHT'!A:A),2))+INDEX('WHO BOY AGE WEIGHT'!A:D,MATCH([Month Age],'WHO BOY AGE WEIGHT'!A:A),2)
If we assume that months increment always by 1 (no gap in month data), you can use something like this formula to interpolate between the two values surrounding the give non-integer value: =(1-MOD(2.3, 1))*VLOOKUP(2.3,A:S,2)+MOD(2.3, 1)*VLOOKUP(2.3+1,A:S, 2) Which interpolates L(2.3) from data of L(2) = .197 and L(3) = .1738, resulting in .19004. You can replace 2.3 by any cell reference. You can also change the lookup column 2 for L into 3 for M, 4 for S etc. To answer the question whether there is some direct "interpolate" function in Excel, not that I know about, although there is good artillery for statistical estimation.
excel- purchase cost function with multiple variables
So I'm not good with excel (computers in general) and can do some things but this one is out of my league. This is the problem: The cost of a used car is highly correlated with the following variables: t= age of car 1 ≤ t ≤ 5 (years) V= volume of engine 1000 ≤ V ≤ 2500 (cubic centimeters) D= number of doors D= 2,3,4,5 A= accessories and style A= 1,2,3,4,5,6 (qualitative) Using regression analysis, the following relationship between the cost and four independent variables was found: purchase cost= (1+1/t)*V*(D/2+A) Plot the purchase price of the car as a function of the four variables. I know how to input the function into excel and only use one number from each variable: Function: =(1+(1/B2))*C2*((D2/2)+E2 Where: B2=1, C2=1000, D2=2, E2=1 Which: A1=4000 (for the purchase cost) What I don't know is how to make the function use multiple number combinations within those variables (i.e. how to change one variable and not the others). I've looked up "youtube" videos and numerous websites to figure this out and none of them showed me what I needed to know. Any help would be greatly appreciated.
I think you have fundamentally solved your problem but there is a typo in your formula which is preventing it from calculating. Add a closing parenthesis at the end your formula. Then assuming that the formula is placed in cell A1 and your example values are placed in the cells indicated in your post, simply type a new numeric value in B2, C2, D2 and/or E2 'manually' and your formula result will update. If you wish you can create a dropdown list in your cells to hold the list of values for each of your variables. This link should get you going.