SUMIFS - No Value Given when using Cell as Criteria - excel-formula

The follow Formula give me the correct Value:
=SUM(SUMIFS('POS Data'!$G:$G,'POS Data'!$B:$B,{"5","10","11"}))
However I require part of the criteria to be taken from a cell value. eg
=SUM(SUMIFS('POS Data'!$G:$G,'POS Data'!$B:$B,E1))
E1 cell value = {"5","10","11"}
However the formula gives a 0 value. What am I missing? Why is it not recognizing that E1 is that value?

The solution used was as follows:
=SUMPRODUCT(SUMIFS('POS Data'!$G:$G,'POS Data'!$B:$B,E1:G1))
E1 = 5
F1 = 10
G1 = 11
That you #scottCraner

Assuming your import cell with your array is in E1, You have to change it from {"5","10","11"} to 5,10,11 in the cell value
=SUM(SUMIFS(G:G,B:B,TRANSPOSE(FILTERXML("<x><y>"&SUBSTITUTE(E1,",","</y><y>")&"</y></x>","//y"))))

Related

Trying to use indirect to make a formula dynamic

Ok, so I am trying to do something I thought was very simple, but it is turning out to be more complicated.
What I am trying to do:
Take a value through an if statement and return 1 or 0. But I want to be able to change the formula by changing values in cells and not editing the formula itself.
Example:
cell A1 = 41%
cell B1 = >
cell C1 = 40%
cell D1 = Formula with calculation
I want to create a formula that will tell me if that 41% is > than 40%, but if I change that > in B1 for a < (in a separate cell outside the cell with the formula) or I change C1 I want it to recalculate.
I have tried the following:
=IF(A1&B1&C1,1,0)
=IF(A1&INDIRECT(B1)&C1,1,0)
=IF(INDIRECT(A1)&INDIRECT(B1)&INDIRECT(C1),1,0)
all of these result in errors and I cannot figure out how to make it work. I am assuming it is taking the > and making it a string instead of a part of the formula.
Thanks for the help.
=COUNTIF( A1, B1&C1 )
... seems to do the trick, although converting C1 to text may give some rounding errors
An alternative would of course be to enumerate all the operations:
=--IFS( B1=">", A1>C1, B1="<", A1<C1 )
And add other operators as you come across them (NB the -- turns TRUE/FALSE into 1/0)

Excel formula for position of minimum value using embedded calculations for arguments

I have this data in Excel
A1 = 12
A2 = 10
A3 = 1
A4 = 6
I would like to return the position of the A1:A3 value that is the shortest distance from A4. Therefore you need to compare the ABS(A1-A4) to ABS(A2-A4) to ABS(A3-A4). The answer in this case is 2.
From Excel formula position of minimum value
the answer should be
=MATCH(2,1/FREQUENCY(MIN(ABS(A1-A4),ABS(A2-A4),ABS(A3-A4)),(ABS(A1-A4),ABS(A2-A4),ABS(A3-A4)))
That returns an error.
Another solution should be
=MATCH(MIN(ABS(A1-A4),ABS(A2-A4),ABS(A3-A4)),{ABS(A1-A4),ABS(A2-A4),ABS(A3-A4)},0)
That also returns an error. I know I can calculate the above in multiple steps(cells) or VBA but I need to have one formula that returns the answer. Thanks.
You need the following simple array formula, enter it then press CtrlShiftEnter
=MATCH(MIN(ABS(A1:A3-A4)), ABS(A1:A3-A4),0)
CtrlShiftEnter

If this value is found in a range, then use the value next to the range result

Hopefully an easy solution:
Look for value of C2 in Column range N3:N300. If found, then put value of P* into D2.
Example:
C2 = "Cat"
Search N3:N300 for "Cat"
Finds N176 = "Cat"
Then makes D2 = value of P176, in this case, "feline"
Is there Excel formula to do this?
You want to use a VLookup function.
https://support.office.com/en-us/article/VLOOKUP-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1

EXCEL How do I ignore a cell if a cell has a value

I have a row that will have weekly values entered. Column B has the initial value, and E has the calculation; as I add values to C, D and so on, I want the calculation to skip the previous columns value when the next column gets a value.
B1-C1=E1 BUT when a value is added to D1, E1 would update to B1-D1=E1
Sorry for the horrible description. This is probably answered somewhere on this site but I am not sure what terms to search.
Many thanks!
you can use an if statement. I am not 100% sure of your problem but something like this might be helpful.
if(A1, A1, 0)
So for your example provided.
=B1-if(D1, D1, C1)
This says if there is a value in D1 use D1 else use C1. This works in this example, because if
D1 is empty or 0 you will use the other cell. This may change for any given problem.
Use this if function in E1:
=IF(D1>0,B1-D1,IF(C1>0,B1-C1,B1))
Then enter a value in B1, then C1 then D1 to see the results.
According to your question, you only have room for two entries after the default B1 value. This statement will handle that.
If you need more fields, nest more if functions. But if's can only be nested 7 deep, so you can only have an initial value in B1 and 7 more cells, C1 to I1 with your formula in J1
If you actual data is as simple as your sample data you could just use:
=IF(LEN(D2)>0, B2-D2,B2-C2)
You could also use:
=IF(ISBLANK(D2), B2-C2, B2-D2)
if you prefer but Len is a little shorter and I believe the ISBLANK() function has flaws, If you have a formula in D2 that has a calculation and you set the result to "" then it will pick up as false. It depends on your needs.
I would do the following.
In E1 paste the following:
=A1-INDEX(B1:D1,1,COUNT(B1:D1))
The count formula will tell how many values are present in the range of B:D column. This will be used to catch the last column with an index formula which will be deducted form A1.
One thing is very important! The values from A to D has to be written in sequence, if one column is missing than the calculation will be false.
Hope I could help!

How to write formula in Excel for my requirement

my requirement as follows:
if a5 = 'a' then b5 = 1
if a5 = 'b' then b5 = 2
if a5 = 'c' then b5 = 3
if a5 = 'd' then b5 = 4
if a5 = 'e' then b5 = 5
else enter correct letter
total no. of conditions are more than 5 as of now and then i need to put default msg for this like 'ENTER CORRECT LETTER '
Excel's IF statement is IF(condition, trueValue, FalseValue). You can nest them to accomplish if-else chains via IF(condition1, trueValue, IF(elseCondition, elseTrue, defaultValue))
Formulas are entered in a cell in Excel by starting the cell's contents with an equals sign.
Conditions of equality in Excel use single equals comparison, not double equals.
There are other ways to approach the problem; if you had a range defined of valid entries, for example, MATCH would be useful for finding the position of a matching cell within that range.
=IF(A5="a",1,
IF(A5="b",2,
IF(A5="c",3,
IF(A5="d",4,
IF(A5="e",5,"Enter Correct Letter")))))
Insert this into cell B5
=IF(OR(CODE(A5)<97,CODE(A5)>101),"ENTER CORRECT LETTER",CODE(A5)-96)
you can see example implimentation in this sheet. Let me know if it helps or you need further explanation.
=IF(ISERROR(FIND(A5,"ABCDE")),"Enter correct letter",CODE(A5)-64)
This will work with as many letters as you want.

Resources