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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.