Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

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

1 ACCEPTED SOLUTION
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

View solution in original post

7 REPLIES 7
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
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

vcgaomsft_0-1684808051752.png

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
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

rajulshah
Resident Rockstar
Resident Rockstar

@Anonymous 

 

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

Anonymous
Not applicable

Below is the screenshot

Shweta_Lendi_0-1684510416260.png

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
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.

Shweta_Lendi_1-1684510814999.png

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

Anonymous
Not applicable

Hi @Anonymous ,

Are there any spelling errors in these positions? Try replacing 0 with o.

vcgaomsft_0-1684722736098.png

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

Note that the type of each column must be text in order to use the & link.

 

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors