Forum Discussion

AllanBerces's avatar
AllanBerces
Icon for Post Prodigy rankPost Prodigy
1 year ago
Solved

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

HrsType NoMat %RESULT
12I0112
2MN 2
51FR 0
40I0 0
5.5MN 5.5
1.6MN 1.6
1.6MN 1.6
1.85M1211.85
9.54M200
8.85I0 0
2.71MN 2.71
0.1M1210.1
0WD 0
42.1MN 42.1
235.21I0 0
67.32M2167.32
6.69MN 6.69
66.42M200
65.46M200
17.45M20.6411.168
25.28M20.51913.12
42.99M200
51.66MN 51.66
14.95M200
14.95MN 14.95
12.69MN 12.69
9.01M200
13.59M200
14.75M200
  • 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-msft's avatar
    v-pnaroju-msft
    Icon for Community Support rankCommunity 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.




  • 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]
    • AllanBerces's avatar
      AllanBerces
      Icon for Post Prodigy rankPost 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

      • Cookistador's avatar
        Cookistador
        Icon for Super User rankSuper 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 ?