Forum Discussion
PQ Multiple IF
Hi good day can anyone help me on my PQ. i have 3 column on my table Hrs, Type No and Mat%.
- 1st condition - IF the column Type No is equal to MN then on the result will be the Hrs
- 2nd condition - IF the Mat% column is blank but the Type No is not MN then the result is 0
- 3rd condition - IF the Mat% is not blank then multiply Mat% to Hrs = Result
RESULT
| Hrs | Type No | Mat % | RESULT |
| 12 | I0 | 1 | 12 |
| 2 | MN | 2 | |
| 5 | 1FR | 0 | |
| 40 | I0 | 0 | |
| 5.5 | MN | 5.5 | |
| 1.6 | MN | 1.6 | |
| 1.6 | MN | 1.6 | |
| 1.85 | M12 | 1 | 1.85 |
| 9.54 | M2 | 0 | 0 |
| 8.85 | I0 | 0 | |
| 2.71 | MN | 2.71 | |
| 0.1 | M12 | 1 | 0.1 |
| 0 | WD | 0 | |
| 42.1 | MN | 42.1 | |
| 235.21 | I0 | 0 | |
| 67.32 | M2 | 1 | 67.32 |
| 6.69 | MN | 6.69 | |
| 66.42 | M2 | 0 | 0 |
| 65.46 | M2 | 0 | 0 |
| 17.45 | M2 | 0.64 | 11.168 |
| 25.28 | M2 | 0.519 | 13.12 |
| 42.99 | M2 | 0 | 0 |
| 51.66 | MN | 51.66 | |
| 14.95 | M2 | 0 | 0 |
| 14.95 | MN | 14.95 | |
| 12.69 | MN | 12.69 | |
| 9.01 | M2 | 0 | 0 |
| 13.59 | M2 | 0 | 0 |
| 14.75 | M2 | 0 | 0 |
Thankyou, Cookistador, for your response.
Hi AllanBerces,We appreciate your inquiry on the Microsoft Fabric Community Forum.
Based on my understanding of the issue, please find attached a screenshot and a sample PBIX file that may help resolve the problem:
We hope the information provided is helpful. If you have any further questions, please feel free to contact the Microsoft Fabric community.Thank you.
5 Replies
- v-pnaroju-msftCommunity Support
Thankyou, Cookistador, for your response.
Hi AllanBerces,We appreciate your inquiry on the Microsoft Fabric Community Forum.
Based on my understanding of the issue, please find attached a screenshot and a sample PBIX file that may help resolve the problem:
We hope the information provided is helpful. If you have any further questions, please feel free to contact the Microsoft Fabric community.Thank you.
- AllanBercesPost Prodigy
Hi v-pnaroju-msft Cookistador thank you very much for the reply, working as i need.
- CookistadorSuper User
Hi AllanBerces
The following PQ should return the desired result as a new custom column
if [Type No] = "MN" then [Hrs] else if [Mat%] = null then 0 else [Mat%] * [Hrs]- AllanBercesPost Prodigy
Hi Cookistador thank you for the reply but it not giving the rigth value especially to 2nd condition, it show 0 to all MN should be the value of hrs column
- CookistadorSuper User
I made a test, with the dataset you shared, and I got the following result (I just lost the decimal when I pasted it)
Can you show me the result of your column? Did you just copy and paste the code I provided ?