How can I write a formula to return a certain number if a result falls within a certain range of numbers? - excel

I am attempting to create a performance report card for my team, but I can't for the life of me write a formula that will return the number rating based on the range the employees result falls in. So, 0-1.49 should equal 1.00, 1.50-2.49 = 2.00, 2.50-3.49 = 3.00, 3.50-4.49 = 4.00, and 4.50 or higher = 5.00.
=IFS(AND(E38>.0149,E38<.0250),2,IF(AND(E38>.0350,E38<.0249),3,IF(AND(E38>.0349,E38<.0450),4,IF(E38>.0449,5,1))))
I keep getting an error stating "there are too few arguments for this function". I am not sure where to go from here. Please Help!

I am sharing in answers only for the reason to show that we can avoid using Nested IF()s function and rather use lookup functions with approximate match, which work better and faster, will be dynamic as well.
• Using LOOKUP() Function --> Applicable from Excel 2007+ onwards.
Formula used in cell F38
=IF(E38="","",LOOKUP(E38,$C$32:$E$36))
• Using VLOOKUP() Function --> Applicable from Excel 2007+ onwards.
Formula used in cell G38
=IF(E38="","",VLOOKUP(E38,$C$32:$E$36,3))
• Using XLOOKUP() Function --> Applicable from Excel 2021+ onwards.
Formula used in cell H38
=IF(E38:E42="","",XLOOKUP(E38:E42,C32:C36,E32:E36,"",-1))
• Using Nested IF() Function --> Applicable from Excel 2007+ onwards.
Formula used in cell I38
=IF(E38="","",IF(E38<=1.49,1,IF(E38<=2.49,2,IF(E38<=3.49,3,IF(E38<=4.49,4,5)))))
• Using Nested IFS() Function --> Applicable from Excel 2019+ onwards.
Formula used in cell J38
=IFS(E38="","",E38<=1.49,1,E38<=2.49,2,E38<=3.49,3,E38<=4.49,4,E38>4.49,5)
• Using Nested SWITCH() Function --> Applicable from Excel 2019+ onwards.
Formula used in cell K38
=SWITCH(TRUE,E38="","",E38<=1.49,1,E38<=2.49,2,E38<=3.49,3,E38<=4.49,4,5)

Related

Lookup Value based on Range

I am looking for a way where I can look up a value based on a value in another cell. In my case i have a scell that holds a sales value and i need to know what the cost would be based in which range it falls in. I know i could do it via endles if statments but i hope there is a way where i can poot on a separate sheet a table in th enclosed pic and the formula would look up which range it would fall under and return the correct charge for the passed in value.
so for example if i pass 620.000 to this function it should return 800 since it is >= to 600.000 and <= 799.999
Try this:
=vlookup(d1,a2:c8,3,1)
Assuming the 620 you suggest is in cell d1.
Also cell A2 needs a 0 not -
With index() and match():
=index(c2:c8,match(d1,a2:a8,1))
Sharing two more alternatives,
• OLDSKOOL Approach --> LOOKUP() Function
=LOOKUP(A10,A2:C8)
• Modern O365 Approach --> XLOOKUP() Function
=XLOOKUP(A10,A2:A8,C2:C8,"None",-1)

How to simplify adding multiple countifs formula in excel

I want to count the number of cells that meet two conditions:
sheet ABC's A2:A100 should be equal to the value of sheet XYC cell A8
the cell value in range D2:M100 = 1
Originally, I tried to use this formula:
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$M$100,1)
But this gave me error #VALUE
I then decided to use the following formula to count each column separately and add them together.
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$D$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$E$2:$E$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$F$2:$F$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$G$2:$G$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$H$2:$H$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$I$2:$I$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$J$2:$J$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$K$2:$K$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$L$2:$L$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$M$2:$M$100,1)
I am wondering if there are any other ways that allows me to shorten my formula?
Thank you.
You can use a boolean structure inside SUMPRODUCT() or just SUM() if your version of Excel supports dynamic arrays (ms365):
=SUMPRODUCT((ABC!A2:A100=XYC!A8)*(ABC!D2:M100=1))

Cumulative Sum Formula using new Excel Dynamic Array Formulas

I'm using the new Dynamic (ie Spill) formulas in Excel. I want a dynamic array that is the accumulation or running total of another dynamic array.
Let's assume I have the following dynamic data in A1:A8:
12
20
14
13
12
13
26
11
To find the differences in this array is trivial:
=OFFSET(A1#,1,0)-A1#
8
-6
-1
-1
1
13
-15
-11
But how do I get the running total using the new dynamic formulas?
12
32
46
59
71
84
110
121
Here's another approach using Matrix Multiplication
=MMULT(TRANSPOSE((ROW(I3#) <= TRANSPOSE(ROW(I3#)))*I3#),SIGN(I3#))
New Answer 2022-06-20
For a dynamic array in A1 use:
=MMULT(N(ROW(A1#)>=TRANSPOSE(ROW(A1#))),A1#)
If the dynamic array in A1 has multiple columns, this returns the cumulative sum of each column, unlike my more complicated Original Answer.
Original Answer 2022-01-13
By using SIGN(I3#), chris neilsen's solution accumulates absolute values. To accommodate negative numbers, replace SIGN(I3#) with 1*(I3#=I3#) in your cumulative sum:
=MMULT(TRANSPOSE((ROW(I3#) <= TRANSPOSE(ROW(I3#)))*I3#),1*(I3#=I3#))
Alternatively, generate a dynamic array of ones with
SEQUENCE(ROWS(I3#),,,0) instead of 1*(I3#=I3#).
(I lack the reputation to comment.)
Cumulative Sum Formula, using SCAN() & LAMBDA() -- Dynamic Spill Array Formulas
• Formula used in cell B1 --> Approach using SCAN() & LAMBDA() --> Applicable To MS365
=SCAN(0,A1:A8,LAMBDA(x,y,x+y))
• Formula used in cell C1 --> Approach using VSTACK(), SCAN() & LAMBDA() --> Applicable to MS365 Office Insiders Beta Channel
=VSTACK(A1,SCAN(A1,A2:A8,LAMBDA(x,y,x+y)))
• Formula used in cell D1 --> Approach using LET(), SCAN() & LAMBDA() --> Applicable to MS365
=LET(x,A1:A8,
sum,LAMBDA(z,y,z+y),
SCAN(0,x,sum))
Using MAP() & LAMBDA()
• Formula used in cell B1
=MAP(A1:A8,LAMBDA(x,SUM(A1:x)))
Here's one way I've done it, but wondering if there's an easier/more efficient way to do it...
=SUBTOTAL(9,OFFSET(A1#,0,0,SEQUENCE(COUNT(A1#))))
This one solves a rolling twelve sum
=SUBTOTAL(9,OFFSET(A1#,SEQUENCE(COUNTA(A1#),1,0),0,12))
You can also use the following:
=SUBTOTAL(9,INDIRECT(CELL("Address",A1)&":"&CELL("address",OFFSET(A1,SEQUENCE(NumberOfRows,0,0,1),0))))
Assume in the above that cell A1 contains the spill formula for the values you want to sum. You can also use a helper column for SEQUENCE(), and if you did that in column B you would use:
=SUBTOTAL(9,INDIRECT(CELL("Address",A1)&":"&CELL("address",OFFSET(A1,B1#,0))))
THIS ALSO WORKS FOR A CUMULATIVE PRODUCT, IF YOU USE =SUBTOTAL(6,...)
I found that the answers given above didn't work for me.
For the matrix multiplication, it works for cumulative sums but it doesn't work for cumulative products. So my answer is a bit more generalised.
For the earlier answers using SUBTOTAL(), for some reason I had to add a number to the values generated by SEQUENCE(). In my case, I had to add 3 which just seemed random. I could find no reason for having to add it, but without it the cumulative sum was out by 3 rows.
My answer doesn't seem to work for the PRODUCT() and SUM() formulae, only for SUBTOTAL(). I'd guess that PRODUCT() and SUM() haven't yet been changed to spill/array type formulae, but SUBTOTAL has.

Two-way look-up in Excel with same values #REF Error

I'm working on a scheduling project for excel.
I'm struggling with a #REF Error when I have more than one VLOOKUP and MATCH
On row 2, the numbers (04,05,06) are formatted as dates for 7/4/2016, 7/5/2016, etc
The table on row 9 (Table8) is where I am entering the dates.
The formula that works fine on B5 is
=IF(VLOOKUP(A3,Table8[[#All],[Name]:[Date]],MATCH(B2,Table8[[#All],[Date]],0),FALSE)=B2,"OFFr","")
A simple copy and paste for C5.. but returns a #REF error
=IF(VLOOKUP(A3,Table8[[#All],[Name]:[Date]],MATCH(C2,Table8[[#All],[Date]],0),FALSE)=C2,"OFFr","")
Your VLOOKUP function is not doing what you think it is. It works in B5 by coincidence that the second row (2) provides the second column in the VLOOKUP's column_num parameter.
Use the AGGREGATE¹ function for the matching date.
=IFERROR(IF(AGGREGATE(15, 6, Table8[date]/((Table8[name]=$A3)*(Table8[date]=B$2)), 1)=B$2, "OFFr"), "")
      
If your Excel is pre-2010 or you need to provide backwards compatibility, there are other two column match formulas available.
Pre-xl2010 two-column-match:
=IFERROR(IF(INDEX(Table8[date],MAX(INDEX((ROW(Table8[name])-ROW(Table8[[#Headers],[name]]))*(Table8[name]=$A3)*(Table8[date]=B$2), , )))=B$2, "OFFr"), "")
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.

when using the sumif function how do you get the [sum_range] to only add the positive numbers?

when using the sumif function how do you get the [sum_range] to only add the positive numbers?
so if the function is =sumif(A:H,C34,H:H) how do I only add the positive numbers in column H
In your posted formula =sumif(A:H,C34,H:H) because the test range is A:H , the range that is summed is actually H:O (the shape of A:H = 8 columns starting at top left cellof H:H) Not sure if this is what you intended. Given the overlap in the criterai and sum ranges I suspect not. BTW this means cell J34 will always be included in the sum
SUMIFS is only available in Exel 2007 and later and would work for =SUMIFS(H:H, A:A, C34, H:H, ">0")
Unlike the range and criteria arguments in the SUMIF function, in the SUMIFS function, each criteria_range argument must contain the same number of rows and columns as the sum_range argument.
If you are using Excel 2003 or earlier, or if the range behviour described above is required, you can use somthing like,
=SUM(H:H*(A:A=$C$34)*(H:H>0))
or
=SUM(H:O*(A:H=$C$34)*(H:O>0)) ' this one won't work as is, you will have to resolve the overlapping ranges
entered as an array formula (Ctrl-Shift-Enter)
You can use the SUMIFS function:
=SUMIFS(H:H, A:H, C34, H:H, ">0")
The sum_range is at the beginning in this case, instead of the end in this case

Resources