Forum Discussion
IF AND SUMIF OR
- 6 years ago
Hi,
This calculated column formula works
=if(AND(CALCULATE(SUM(Data[hours]),FILTER(Data,Data[Name]=EARLIER(Data[Name])))>=10,Data[method]="face"),"Eng",IF(AND(CALCULATE(SUM(Data[hours]),FILTER(Data,Data[Name]=EARLIER(Data[Name])))>=20,OR(Data[method]="online",Data[method]="face")),"PS",IF(AND(Data[status]="pass",Data[priority]="CS"),"Up","Unknown")))Hope this helps.
- 6 years ago
Anonymous - I did find one slight error in Anonymous's formula so I corrected it and did some formatting. PBIX is attached.
Result Output = VAR __Sum = SUMX(FILTER(ALL('Table'),[Name]=EARLIER([Name])),[hours]) RETURN SWITCH( TRUE(), __Sum >= 10 && [method]="face","Eng", __Sum >= 20 && ([method]="face" || [method]="online"),"PS", [status] = "pass" && [priority] = "CS","Up", "Unknown" )
OK, the replacement for SUMIF is to use SUMX with a FILTER or wrap a SUM with CALCULATE and a filter. IF, AND and OR are all the same as excel. However, I would use a SWITCH TRUE statement because nested IF statements give me the willys. I don't speak much Excel and I don't want to go look up SUMIF so what is the SUMIF doing? Can you explain your Excel formula in non-code?
- Anonymous6 years agoNot applicable
Please see what am trying to archieve in none code format :
Eng = must have at least 10 hours and status = FACEPS=Hours = At Least 20 hours and status = Face OR onlineUP: Status = Pass and Priority = CS Accelerator .I hope this helps Greg_Deckler- Greg_Deckler6 years agoCommunity Champion
Sure, let me know if Anonymous 's solution didn't work for you, looks solid to me.
- Greg_Deckler6 years agoCommunity Champion
Anonymous - I did find one slight error in Anonymous's formula so I corrected it and did some formatting. PBIX is attached.
Result Output = VAR __Sum = SUMX(FILTER(ALL('Table'),[Name]=EARLIER([Name])),[hours]) RETURN SWITCH( TRUE(), __Sum >= 10 && [method]="face","Eng", __Sum >= 20 && ([method]="face" || [method]="online"),"PS", [status] = "pass" && [priority] = "CS","Up", "Unknown" )- Anonymous6 years agoNot applicable
Greg_Deckler Thanks for your help, I created a matrix with the result of the calculated column and DISTINCTCOUNT(id) for my measure as I want to distinct count of the id but the total is not suming up. I have updated my table with a new column "ID" . And also attached pictures of my table and matrix visual .
culated column and
Name hours method status priority Result Output ID Ade -15 face pass CS Up 57YE43YGD Ade 5 face pass CS Up 57YE43YGD ade 5 face pass CS Up 57YE43YGD Ade 5 face pass CS Up 57YE43YGD Ade 5 online pass cs Up 57YE43YGD Alex 5 face pass cs Eng 87HBDGD Alex 5 face cs Eng 87HBDGD Alex 5 online cs PS 87HBDGD Alex 5 online cs PS 87HBDGD Alex 5 online cs PS 87HBDGD Alex 5 online cs PS 87HBDGD Alex 5 face CS Eng 87HBDGD Chris 5 face fail wweee Eng OU2809 chris 5 face fail wweee Eng OU2809 chris 5 face fail wweee Eng OU2809 Chris 5 online fail wweee PS OU2809 chris 5 online fail wweee PS OU2809 chris 5 online fail wweee PS OU2809 Chris 5 online fail wweee PS OU2809 chris 5 face fail wweee Eng OU2809 chris 5 face fail wweee Eng OU2809 Ola 5 face fail wweee Eng URH879 ola 5 face fail wweee Eng URH879 Tobi 5 online fail wweee PS HGT153 tobi 5 face fail wweee Eng HGT153 tobi 10 face fail wweee Eng HGT153