Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

And OR not working in power Query

I have the below code and in this part AND and OR part is not working.KIndly help

if [Control]="ENG0N" and ([SubControl]="ENG0N.A6" or
[SubControl]="ENG0N.IPE")
then [Month]&[Year]&[SubControl]
else if [Control]="ENG0N" and ([SubControl]<>"ENG0N.A6" or
[SubControl]<>"ENG0N.IPE")
then [Month]&[Year]&[SubControl]
else null

 

can anyone please help me

  • Anonymous's avatar
    Anonymous
    3 years ago

    I completely agree with this solution but somehow in some cases the combination of OR and <> is not working properly. In my case, for some blocks its working and for some its not though the logic is same. So, instead of OR and <> I have used nested if else again.

     

    Thanks,

    Shweta

7 Replies

  • rajulshah's avatar
    rajulshah
    Resident Rockstar

    Anonymous 

     

    Can you please share sample data and the output that you are getting?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Below is the screenshot

      Basically if its A6 and IPE I dont want to concatenate week else include week in the concatenation.

      I have given expected output. Error which I am facing is for all A field I am getting week in the concatenated field.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Apologies,posting the rith screenshot(chnaged B field)

        Criteria is to check B field first and if it matches then check A field for A6 and IPE and do the concatenation.

        Kindly help..I have to do this in power query

  • Anonymous's avatar
    Anonymous
    Not applicable

    No..its zero...it's sample data. All columns are text. OR operator working in some cases and in some cases it's not working.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous ,

      Please try:

      = if [Control]="ENG0N" and ([SubControl]="ENG0N.A6" or
      [SubControl]="ENG0N.IPE")
      then [Month]&Text.From([Year])&[SubControl]
      else if [Control]="ENG0N" and ([SubControl]<>"ENG0N.A6" or
      [SubControl]<>"ENG0N.IPE")
      then [Month]&[Week]&Text.From([Year])&[SubControl]
      else null

      Best Regards,
      Gao

      Community Support Team

       

      If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

      How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

      • Anonymous's avatar
        Anonymous
        Not applicable

        I completely agree with this solution but somehow in some cases the combination of OR and <> is not working properly. In my case, for some blocks its working and for some its not though the logic is same. So, instead of OR and <> I have used nested if else again.

         

        Thanks,

        Shweta