SUM IF when a text string meets a specific numeric value - excel

Okay it might sound weird but I need to calculate points for each employee where:
LT(Tardy) = 0.50 pts
A(Absent) = 1 pt
The table looks like this:
12/1/22 12/2/22 12/3/22 12/4/22 Total Points
A LT LT LT ?
Can I calculate total points in a range where LT is 0.50 pts and A = 1 pt??
Thanks!!
I can not figure out SUMIF to calculate total where a text string meets a specific numeric value

FWIW, you can also use arrays of criteria and values like this:
=SUM(COUNTIF(A2:D2,{"A","LT"})*{1,0.5})

I know, I am late, as the solutions posted by Scott Craner Sir, & Rory Sir are very useful, however sharing one more alternative way.
• Formula used in cell E2
=SUM((A2:D2={"A";"LT"})*{1;0.5})
Let me show you what it creates, before wrapping within SUM()
It creates an array of 2 rows x 4 columns, next we are multiplying by {1;0.5} matrix calculation,
Last but not least to get the counts we are summing the matrix which returns 2.5.

Use COUNTIFS:
=COUNTIFS(A2:D2,"A")+COUNTIFS(A2:D2,"LT")/2

A short one for this specific case (two possible values):
=SUM(IF(A2:D2="A",1,0.5))

Related

Excel: How to find closest number in table, many times

Excel
Need to find nearest float in a table, for each integer 0..99
https://www.excel-easy.com/examples/closest-match.html explains a great technique for finding the CLOSEST number from an array to a constant cell.
I need to perform this for many values (specifically, find nearest to a vertical list of integers 0..99 from within a list of floats).
Array formulas don't allow the compare-to value (integers) to change as we move down the list of integers, it treats it like a constant location.
I tried Tables, referring to the integers (works) but the formula from the above web site requires an Array operation (F2, control shift Enter), which are not permitted in Tables. Correction: You can enter the formula, control-enter the array function for one cell, copy the formulas, then insert table. Don't change the search cell reference!
Update:
I can still use array operations, but I manually have to copy the desired function into each 100 target cells. No biggie.
Fixed typo in formula. See end of question for details about "perfection".
Example code:
AI4=some integer
AJ4=MATCH(MIN(ABS(Table[float_column]-AI4)), ABS(Table[float_column]-AI4), 0)
repeat for subsequent integers in AI5...AI103
Example data:
0.1 <= matches 0
0.5
0.95 <= matches 1
1.51 <= matches 2
2.89
Consider the case where target=5, and 4.5, 5.5 exist in the list. One gives -0.5 and the other +0.5. Searching for ABS(-.5) will give the first one. Either one is decent, unless your data is non-monotonic.
This still needs a better solution.
Thanks in advance!
I had another problem, which pushed to a better solution.
Specifically, since the Y values for the X that I am interested in can be at varying distances in X, I will interpolate X between the X point before and after. Ie search for less than or equal, also greater than or equal, interpolate the desired X, then interpolate the Y values.
I could go a step further and interpolate N - 1 to N + 1, which will give cleaner results for noisy data.

Excel sum based on matrix condition and multiple criteria

Following from the example here I'm trying to add additional conditions to a sum formula. I've represented an example below:
The output that I'm looking for for example for Jan 2017 is
2017
1
UP A 1
UP B 6
UP C 6
DOWN A 1
DOWN B 8
DOWN C 7
I tried with the following formula:
=MMULT(--($B$17:$C$17="X"),MATCH(1,($A23=$C$2:$C$14)*(C$21=$A$2:$A$14)*(C$22=$B$2:$B$14)*($E$2:$E$14=$D$2:$D$14),0))
but I get a N/A value.
Does anyone know it if is possible to do it?
In your first example the number of rows in array1 and number of columns in array2 were equal, five. Here you have two columns and 13 rows. That they are unequal here is part (all) of the reason why you are having an issue.
Also your match function is returning a Boolean not an array
I have a way to do this using matrix condition and multiple criteria but had to change problem up a bit, see photo for example:
{=MMULT(--(D18:P18="x"),E$2:E$14*(--(A$2:A$14=$C$21)*--(B$2:B$14=$C$22)*--(C$2:C$14=A24)))"
https://i.stack.imgur.com/FEvgR.png
You can create a formula to fill the second matrix with X's see below
=IF(OR(INDIRECT("D"&VALUE(D20))=$A$18,INDIRECT("D"&VALUE(D20))=$B$18),"X","")
https://i.stack.imgur.com/4rS4L.png
That being said I don't think this is particularly efficient as you are treating the one of the matrixes as a all 1's so you basically just adding an extra criteria / Boolean with added complexity....that being said u asked for this specifically and I believe that I have delivered that LOL
Just add two SUMIFS together.
=SUMIFS($E$2:$E$14, $A$2:$A$14, C$21, $B$2:$B$14, C$22, $C$2:$C$14, $A23, $D$2:$D$14, IF(INDEX($B$17:$C$19, MATCH($B23, $A$17:$A$19, 0), 1)="x", $B$16))+
SUMIFS($E$2:$E$14, $A$2:$A$14, C$21, $B$2:$B$14, C$22, $C$2:$C$14, $A23, $D$2:$D$14, IF(INDEX($B$17:$C$19, MATCH($B23, $A$17:$A$19, 0), 2)="x", $C$16))

Complicated counting in excel

I have the following columns in Excel
a b c
1 SUM 1st 2nd
2 0 2/2 2/4
3 0 1/1 3/4
b2 is defined as "=CONCATENATE(TRUNC(2);"/";TEXT(('Other sheet'!B2);0))"
and similar to b3,c2,c3.
Column |SUM| should count sum from |1st| to |2nd| but only the first numbers before "/".
for example: b2+c3+... = 2+2+... = 4+... so a2=4+...
any ideas how to do that? :)
Use the below formula with feature shift+ctrl+enter:
=SUM(TRUNC(MID(B2:C2,1,SEARCH("/",B2:C2,1)-1)))
You can use the 'left' function
Use it like this
A2=left(B2;1)+left(C2;1)
Here's a simple way to do it
=SUMPRODUCT(INT(SUBSTITUTE(B2:C2,"/",".")))
Extend your range as far as you need by changing B2:C2 to B2:X2, for example.
I think this might work for your system.
=SUMA.ILOCZYNÓW(ZAOKR.DO.CAŁK(PODSTAW(B2:C2;"/";".")))

Excel If Else Formula comparing string values

First I'm no Excel formula guru..
I want to write a formula that is comparing 4 possible string values
such as: Up, Down, Left, Right
pseudocode would be say:
if a1="Up" and a2="Down" then 1.1
else if a1="Left" and a2="Right" then 1.1
else if a1="Left" and a2="Down" then .95
else if a1 = a2 then 1
I'd cover all the permutations..
I view it as 6 nested if tests
4 items to test/compare
6 tests emerge
1x2,1x3,1x4,2x3,2x4,3x4
=IF(1=2,do this,if(1=3,do this,if(1=4,do this,if(2=3,do this,if(2=4,do this,if(3=4,do this,value if every test fails))))))
I THINK Excel has a limit of 7 nested if formulas or perhaps even formulas in general.
Perhaps you're looking for something like this?
=IF("Test1"="","Equal1
","")&IF("Test2"="","Equal2
","")&IF("Test3"="","Equal3
","")&IF("Test4"="","Equal4
","")
Borrowed from basically the same question on SuperUser.

Binning in Excel

Which formulae in MS Excel can we use for -
equi-depth binning
equi-width binning
Here's what I used. The data I was binning was in A2:A2001.
Equi-width:
I calculated the width in a separate cell (U2), using this formula:
=(MAX($A$2:$A$2001) - MIN($A$2:$A$2001) + 0.00000001)/10
10 is the number of bins. The + 0.00000000001 is there because without it, values equal to the maximum were getting put into their own bin.
Then, for the actual binning, I used this:
=ROUNDDOWN(($A2-MIN($A$2:$A$2001))/$U$2, 0)
This function is finding how many bin-widths above the minimum your value is, by dividing (value - minimum) by the bin width. We only care about how many full bin-widths fit into the value, not fractional ones, so we use ROUNDDOWN to chop off all the fractional bin-widths (that is, show 0 decimal places).
Equi-depth
This one is simpler.
=ROUNDDOWN(PERCENTRANK($A$2:$A$2001, $A2)*10, 0)
First, get the percentile rank of the current cell ($A2) out of all the cells being binned ($A$2:$A$2001). This will be a value between 0 and 1, so to convert it into bins, just multiply by the total number of bins you want (I used 10). Then, chop off the decimals the same way as before.
For either of these, if you want your bins to start at 1 rather than 0, just add a +1 to the end of the formula.
Best approach is to use the built-in method:
http://support.microsoft.com/kb/214269
I think the VBA version of the addin (step 3 with most versions) will also give you the code.
Put this formula in B1:
=MAX( ROUNDUP( PERCENTRANK($A$1:$A$8, A1) *4, 0),1)
Fill down the formula all across B column and you are done. The formula divides the range into 4 equal buckets and it returns the bucket number which the cell A1 falls into. The first bucket contains the lowest 25% of values.
General pattern is:
=MAX( ROUNDUP ( PERCENTRANK ([Range], [TestCell]) * [NumberOfBuckets], 0), 1)
You may have to build the matrix to graph.
For the bin bracket you could use =PERCENTILE() for equi-depth and a proportion of the difference =Max(Data) - Min(Data) for equi-width.
You could obtain the frequency with =COUNTIF(). The bin's Mean could be obtained using =SUMPRODUCT((Data>LOWER_BRACKET)*(Data<UPPER_BRACKET)*Data)/frequency
More complex statistics could be reached hacking around with SUMPRODUCT and/or Array formulas (which I do not recommend since are very hard to comprehend for a non-programmer)

Resources