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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Hyperchef1969
Helper V
Helper V

Dax does not accept IF AND OR statement

Hi,

 

I am trying to make a new column including an 'if or' statement which also includes a nested OR. This in the presentation mode (not in query mode)

 

Can somebody help how I should write this? When writing 'IF(OR(....' the OR is not accepted. OR is marked with a red waved line beneeth.

 

Thanks in advance.

1 ACCEPTED SOLUTION

OK, I created a table like this:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkvMKUstVorViVYKTk0sgbACEvNArFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ARTICLE_GROUP_NAME = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ARTICLE_GROUP_NAME", type text}})
in
    #"Changed Type"

And copied your formula into a new column and it worked perfectly. Even as a slicer. Only thing I can think of if you are getting blanks in your slicer is that you have something else filtering the page?

 

 

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Can you post the full formula? OR is a valid DAX function. For example, this formula is valid in my test:

 

Measure 2 = IF(OR(MAX('Table1'[Name])="Bloggs",MAX('Table1'[Name])="Smith"),"Smith","Not Smith") 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

This is the formula:

 

Article_Group = if(OR([ARTICLE_GROUP_NAME]="Valves",[ARTICLE_GROUP_NAME]="Seats"),"Wear_parts","Others")

 

When I use a slicer, it results in 'blanks'.

Hi @Hyperchef1969,

 

Have you solved your problem?

 

If you have solved, welcome to share your solution or mark the right reply as answer. More people will find the solution easily.

 

If you still need help, could you share a dummy pbix file which can reproduce the scenario, so that we can help further investigate on it? You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.)

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

OK, I created a table like this:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkvMKUstVorViVYKTk0sgbACEvNArFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ARTICLE_GROUP_NAME = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ARTICLE_GROUP_NAME", type text}})
in
    #"Changed Type"

And copied your formula into a new column and it worked perfectly. Even as a slicer. Only thing I can think of if you are getting blanks in your slicer is that you have something else filtering the page?

 

 

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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