Forum Discussion
IF Statement Not Working
- 2 years ago
Hi
It's normal that shows 0 beause 74.17 is greather than 60. If you just want to calculate for hours >60 change your code like this
= IF(AND(ABCTEMPS[Total by Emp and Week]>40, ABCTEMPS[Total by Emp and Week]>60), 20,0)
and if you want for all calculations:
= IF(AND(ABCTEMPS[Total by Emp and Week]>40, ABCTEMPS[Total by Emp and Week]<60), ABCTEMPS[Total by Emp and Week]-40,IF(ABCTEMPS[Total by Emp and Week]>60,20,0))
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
- Anonymous2 years agoNot applicable
It would be very hard to upload a file with no sensitive information, as their is so much sensitive info to cleanse. I think I gave too much info in my original post. The only Dax formula that I need help with is the
OT 1.5 Dax:
= IF(AND(ABCTEMPS[Total by Emp and Week]>40, ABCTEMPS[Total by Emp and Week]<60), ABCTEMPS[Total by Emp and Week]-40,0)If an employee worked 74.17 hours in a week, I need the "OT 1.5" column to show 20 hours (which is the amount of hours between 40 and 60. Right now it shows 0. Any help is greatly appreciated.- JamesFR062 years agoResolver IV
Hi
It's normal that shows 0 beause 74.17 is greather than 60. If you just want to calculate for hours >60 change your code like this
= IF(AND(ABCTEMPS[Total by Emp and Week]>40, ABCTEMPS[Total by Emp and Week]>60), 20,0)
and if you want for all calculations:
= IF(AND(ABCTEMPS[Total by Emp and Week]>40, ABCTEMPS[Total by Emp and Week]<60), ABCTEMPS[Total by Emp and Week]-40,IF(ABCTEMPS[Total by Emp and Week]>60,20,0))
- Anonymous2 years agoNot applicable
Your second DAX formula worked like a charm. The OT 1.5 column now shows 20 hours for each row where an employee worked over 60 hours. Thank you!