I want to be able to use sumifs() for two conditions. If the section is groceries and the month is September, I want it to sum it. If I take away the second condition, it sums the 286.55, but if I leave the second condition in sumifs() then it gives me 0.
I can think of one of two issues...
1 You are trying to match a date with a string. To check I would do a =B2*1 & =I2*1. If both of them give error then you are ok.
2 The strings are different(one of them has a trailing space etc.) Try =LEN(B2) & LEN(I2). I'm sure one of them is >9.
You would know what to do by yourself
Related
I have a sheet that shows max values spent anywhere. So I need to find most expensive place and return it's name. Like this:
Whole sheet.
Function.
Function in text:
=IFS((A6=MAX(D2:D31)),(INDEX(C2:C31,MATCH(A6,D2:D31,0))),(A6=MAX(H2:H31)),(INDEX(G2:G31,MATCH(A6,H2:H31,0))),(A6=MAX(K2:K31)),(INDEX(K2:K31,MATCH(A6,L2:L31,0))))
Basically I need to find a word left to value, matching A6 cell.
Thanks in advance.
Ok.. Overcomplicated!
Firstly, why the three rows? it's a lot easier if you just have one long row with all the data (tell me if you actually need 3 I'll change my solution)
=LOOKUP(MAX(D2:D31);D2:D31;C2:C31)
The MAX formula will lookup the biggest value in the list, the Lookup formula will then match it to the name.
Please note: If more than one object has the maximum price, it will only return the first one. The only way I can think of to bypass that would be to build a macro.
EDIT:
Alright.. Multi Column solution is ugly and requires extra columns that you can just hide.
As you can see you'll need 2 new columns that will find the highest for each row, 2 new columns that will find the value for each of these "highest" (in this case tree and blueberries) and then your visible answer will simply be an if statement finding out which one is bigger and giving the final verdict. This can be expanded with an infinite number of columns but increases complexity.
Here are the formulas:
MAX(H2:H31)
LOOKUP(A5;H2:H31;G2:G31)
MAX(L2:L31)
LOOKUP(C5;L2:L6;K2:K6)
IF(A5>C5;B5;D5)
In the beginning I used this formula SUBTOTAL(3;(A14:A150>0)) and it works perfectly but now I need to add a condition that I must count the number of rows where the value in the column F is greater than 0.
This formula COUNTIF(F14:F150;">0") return the right result, but when I filter I don’t have the right one.
I tried also SUMPRODUCT(SUBTOTAL(3;F14:F150)/A1*(F14:F150>0)) it return the same thing as the COUNTIF.
You can add another column with formula:
=IF(SUBTOTAL(103;F14))
Because you are using filters this formula will help you determine if your cell is hidden or not.
Now you can use, assuming that latter formula is in column G:
=COUNTIFS(F14:F150;">0";G14:G150;">0")
Array-entered using Ctrl+Shift+Enter:
=SUMPRODUCT(--(F14:F150>0),IF(SUBTOTAL(3,OFFSET(F14:F150,ROW(F14:F150)-MIN(ROW(F14:F150)),,1)),F14:F150,""))/A1
I don't get exactly your needs but you may want to use
=SUMIFS(F14:F150,F14:F150,">0",A14:A150,">0")
or
=COUNTIFS(F14:F150,">0",A14:A150,">0")
I was playing around with a couple ideas to count unique text based on two criteria. I was thinking Sumproduct would do it for me, but it doesn't seem to work. I may need some kind of VBA script. Basically, I want to do the following.
1) Look at everything in ColumnB and if that matches a criteria
2) Look at everything in ColumnW and if that matches a criteria
3) Count unique text in ColumnF.
It's almost like this:
=COUNTIFS(W:W,A1,B:B,B1)
THEN, based on the result of that, count uniques in ColumnF
I was thinking this should be pretty easy, but it's turning out to be really hard!
You can use a standard SUMPRODUCT-based pseudo-COUNTUNIQUE but you need to modify it by adding the criteria in the numerator and also the inverse criteria in the demononator; the latter to avoid #DIV/0! errors. This will generate a pseudo-COUNTIFSUNIQUE.
=SUMPRODUCT(SIGN((B2:B20="bee")*(W2:W20="double-you"))/
(COUNTIFS(B2:B20, "bee", W2:W20, "double-you", F2:F20, F2:F20)+(B2:B20<>"bee")+(W2:W20<>"double-you")))
Another solution is to adapt the formula from here: Count Unique Text Values in a Range.
Instead of using F:F, you modify it to match F:F if both Crit1 and Crit2 hold and "No Match" otherwise. That is,
IF((B:B="Crit1")*(W:W="Crit2"),F:F,"No Match")
Then you do a unique count on that array.
=SUMPRODUCT(--(FREQUENCY(MATCH(IF((B:B="Crit1")*(W:W="Crit2"),F:F,"No Match"),
IF((B:B="Crit1")*(W:W="Crit2"),F:F,"No Match"),0),
ROW(F:F)-ROW($F$1)+1)>0))
-NOT(PRODUCT((B:B="Crit1")*(W:W="Crit2")))
The -NOT(PRODUCT(...)) at the end is to subtract the unique count for the "No Match" entry if it exists (this can be replaced by just -1 if you know there will always be things that don't match both criteria).
Note that this is an array formula and must be entered using Ctrl+Shift+Enter.
This is a continuation of " Is it possible to write a VBA code that searches for the exact same data or the closest one in the past? "
Basically I would like to expand the function that #Jeeped posted but for some reason it's not going as planned eventhough I'm doing the same stuff he showed.
The extra condition in this case is that the machine used to produce the juice must be equivalent to the machine of the parameters.
(the image of what I'm doing)
Basically if a juice is made on 29/09 with machine M0 for example then I want to have the parameters that were used for that juice. Obviously the parameters of 30/09 weren't used but the parameters of 25/09 for machine M0 were used.
I edited the code #Jeeped posted in my previous question to the following
=IFERROR(INDEX(C$2:C$10, MIN(INDEX(ROW($1:$10)+($A$2:$A$10>$F2)*1E+99+($B$2=$G$2),,))),"")
But I get an error and I'm not sure why but I have a feeling it has to do with what I wrote ($B$2=$G$2) but how do I fix it?
DISCLAIMER: the percentages used are fictive, it's just a function I need to get working for several Workbooks that will automate some work I need to do every month.
It looks like you want to add the condition that columns B should match G2. This should do the trick.
=IFERROR(INDEX(C$2:C$10, MIN(INDEX(ROW($1:$9)+(($A$2:$A$10>$F2)+($B$2:$B$10<>$G2))*1E+99,,))),"")
This type of formula does not make direct matches. It excludes everything that doesn't match and then accepts whatever is left over. So like the date in F2 is compared to the dates in column A and anything that is larger (i.e. later) is multiplied by a very large number. We do the same to the machine ID in G2. Anything that does not match the machines in column B get multiplied by the same very large number. By mathematically excluding anything that doesn't fit, we are left with what does fit.
It is also important to note that the ROW(1:9) is the position within C2:C10 or A2:A10, not the actual row on the worksheet.
Addendum: With the dates now unsorted, I can provide both a standard and an array formula to compensate. The array formula for I2 is,
=SUMIFS(C$2:C$10,$A$2:$A$10,MAX(IF($A$2:$A$10<=$F2,IF($B$2:$B$10=$G2,$A$2:$A$10))),$B$2:$B$10,$G2)
This must be finalized with Ctrl+Shift+Enter rather than simply Enter. Once entered correctly, it can be filled both right and down. Next is a standard formula that does not require Ctrl+Shift+Enter but accomplishes the same thing. Your results should resemble the following image.
=SUMIFS(C$2:C$10, $A$2:$A$10,MAX(INDEX(($A$2:$A$10<=$F2)*($B$2:$B$10=$G2)*($A$2:$A$10),,)),$B$2:$B$10,$G2)
I think the formula below might answer your question. Please see the image for reference.
Formula Used: =INDEX($D$2:$E$7,MATCH(1,($B$2:$B$7<$H3)*($C$2:$C$7=$I3),0),1)
Please note - this requires your date of parameter change to be sorted from newest to oldest.
To apply this formula, press CTRL+SHIFT+ENTER after writing the formula. This is required for excel to understand that this should function as an Array formula. On doing so, excel will automatically add the curley brackets at the beginning and end of the formula as can be seen in the image.
Only small difference for formula to get %Oranges will be replacing the last 1 by 2.
INDEX($D$2:$E$7,MATCH(1,($B$2:$B$7<$H3)*($C$2:$C$7=$I3),0),2)
Hope this answers your question. Please let me know if you need further assistance.
I have a few reports built using Report Builder 3 for MSSQL 2008 Reporting Services.
Some fields in my report are showing "#Error", instead of this I want to show only a simple "-". Is there any built-in function or custom code to overcome this?
I'd still really like to see your formula but you seem determined not to show it, so I'll take a wild stab at answering without it. I imagine that you are doing something like dividing the field on the current row by the field on the previous row. However, this would give you Infinity on the first line rather than #Error so there is something else going on. But let's run with this anyway since we don't have your formula.
The most common way to solve this is to check for Nothing being returned for the Previous function, usually indicating that you are on the first row (assuming your field always has data). This has the advantage of also working on fields that are not guaranteed to have a value.
=IIF(IsNothing(Previous(Fields!MyField.Value)), "-", Fields!MyField.Value / Previous(Fields!MyField.Value))
Here is another way you could do it using the row number, which will always check for the first row regardless:
=IIF(RowNumber(Nothing) = 1, "-", Fields!MyField.Value / Previous(Fields!MyField.Value))
This assumes that the error is being caused by the Value formula and not by some other mechanism such as applying an expression to other properties like Format, Color which is invalid when there is no previous row.