Complicated counting in excel - 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;"/";".")))

Related

SUM IF when a text string meets a specific numeric value

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))

Extract words before a specific pattern

I have a column with different names in the rows:
hello_world_xt_x_D3_m6
bye_bye_x_D1_m3
h1_man_xt_x_D3_m6
bonjour_no_x_D1_m12
I would like to remove the ending part which follows the pattern
_x_DN_mZ
where N is a number between 0 and 3 and Z is a number between 0 and 16.
I would like to have
hello_world_xt
bye_bye
h1_man_xt
bonjour_no
I think I should use a combination of search and trim/right, but I do not know how to apply it.
I have tried with =substitute(a2, "_x_D2_m3","") but I do not know how to extend it regardless the numbers which follows D and m
You could use Wildcards (See the ? in the search string)
EDIT: replace second ? with *
Formula: =LEFT(A2,SEARCH("_x_D?_m*",A2)-1)
With data in column A, in B1 enter:
=MID(A1,1,FIND("_x_",A1)-1)
and copy downward:
Would this do?
=LEFT(A2,FIND("_x_",A2)-1)

If-Else ladder in Excel To sort data

I was doing R&D on Excel. And wanted to use If-else ladder in column of excel.
Let's say I have a 2 columns and I calculated the difference between the two columns. Now, If the difference is between a range of (-5 to +5), if should display something or if Difference greater than 5, it should display something and for rest i.e. difference < -5, should display something else.
I tried and came up with this
=IF("H2>5",<something1>, IF("H2<5",<something2>))
How to put the range part in this if-else ladder? Also the above If else is not giving value but the result is turning out to be #VALUE.
Thanks for your help.
Try
=IF(H2<-5,"Negative",IF(H2<=5,"In Range","Positive"))
There could be 3 possibilities only, 1 the answer is between -5 to 5 inculdining -5 and 5. 2 greater then 5. 3 smaller than -5. so this should work
=IF(AND(H2>=-5,H2<=5),"between -5 &5",IF(H2<-5,"Smaller than-5",IF(H2>5,"greater than 5 ")))
let me know if this is what is required.

How to exclude 0 when using RandBetween?

Essentially, I want to have a random + or - so I'm using a RandBetween(-1,1). However, when the value is value is zero, I obviously get the same number I started off with. Is there a way to exclude the zero?
Thanks in advance!
Excel Example:
=J1+(J1*RAND()*RANDBETWEEN(-1,1)*0.1)
This will select 1 or -1 with 50% probability:
=IF(RAND()<0.5, 1, -1)
For fun, here is a different solution which uses RandBetween:
=(-1)^RANDBETWEEN(0,1)

Use cell X3 in function with lookup

Hey guys I have a bunch of strings in a column and I am getting the row number of the last string by using the following:
=MATCH(REPT("z",255),StaticData!G:G)
It gives me a number 256 and it is in cell X3.
I am using a lookup and I would like to specify this number in cell X3:
=IFERROR(VLOOKUP(A2,Sheet1!$C$4:$D$256,2,0),"")
Where the 260 is right now I would like to place X3 but it is giving me errors.
So like:
=IFERROR(VLOOKUP(A2,Sheet1!$C$4:$D$X3,2,0),"")
Anyone know how I can do this? Thanks!
You are looking for Offset:
=IFERROR(VLOOKUP(A2,Sheet1!$C$4:OFFSET($D$1,$X$3-1,0),2,0),"")
In most cases INDEX is preferable to OFFSET because OFFSET is a volatile function - try this version
=IFERROR(VLOOKUP(A2,Sheet1!$C$4:INDEX(Sheet1!$D:$D,$X$3),2,0),"")

Resources