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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX (And and OR)

 
1 ACCEPTED SOLUTION

@Anonymous  Hi, This error happens when data types taht you are trying to compare e.g. using "=" are different. E.g. you could have a column with value like "1" and another which is 1. Since the first one is string and the second one is number the comparison doesn't work.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
AlexisOlson
Super User
Super User

As mentioned already, you can use && and || to compose expressions with as many arguments as you'd like. For example,

 

[AY] = "NB" || [AY] = "" || [AY] = "Out Of Scope"

 

A couple of other things are also worth mentioning.

The IN syntax. The DAX above can also be written as:

 

[AY] IN { "NB", "", "Out of Scope" }

 

The SWITCH function. The SWITCH ( TRUE, ... ) construction is particularly powerful. See here:

https://p3adaptive.com/2015/03/the-diabolical-genius-of-switch-true/

Whitewater100
Solution Sage
Solution Sage

HI: If you need to perform an AND operation on multiple expressions, you can create a series of calculations or, better, use the AND operator ( &&) to join all of them in a simpler expression.

 

OR logical operator is ||

 

Hope this helps

ValtteriN
Super User
Super User

Hi,

You can use OR and AND operators to add more conditions for or it is || and for and it is &&

e.g. Measure 12 will return Y since one of the conditions is true

Measure 12 = if(1=2 || 1=3 || 1=1 , "Y", "N")

Measure 13 will return N since only one of the conditions is true

Measure 13 = if(1=2 && 1=3 && 1=1 , "Y", "N")

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you! @ValtteriN 

 

I used || and && and wrote the formula.

 

But I get an error "DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.".

I tried using format, still getting an error.

Can I know whats the problem?

 

Thank you!

Megha

Anonymous
Not applicable

@ValtteriN  Can I please know what can be done for the above error?

I tried using Format, but it remains the same.

Thank you!

Megha

The most likely cause of this error is if your [Order Cycle] column is a text data type or one of the other columns references is not a text column.

@Anonymous  Hi, This error happens when data types taht you are trying to compare e.g. using "=" are different. E.g. you could have a column with value like "1" and another which is 1. Since the first one is string and the second one is number the comparison doesn't work.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors