cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
A_Barny Frequent Visitor
Frequent Visitor

Wrong syntax for IF

Hi everyone,

 

I am beginner on Power BI and I try to do a new colonne on my dataset.

I don't understand why my DAX syntaxe is not correct .

 

I try to use 2 differents fields on same table for déterminate a new name with this two.

I would use a SWITCH because I think it's better but it can't use 2 différents fields.

 

Territory = if([Market] = "Sport" && [Region DO] = OR ("CA";"WA"); "NorthWest";0)

 

Could you help me please ?

 

Thanks,

Alex

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Wrong syntax for IF

Hi @A_Barny,

 

OR function is used to check multiple logical expressions and return true if one of these expressions can be achieved, I'd like to suggest you use 'in' keywords to instead.

Territory =
IF ( [Market] = "Sport" && [Region DO] IN { "CA"; "WA" }; "NorthWest"; 0 )

Regards,

Xiaoxin Sheng

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



For learning resources/Release notes, please visit: | |
1 REPLY 1
Highlighted
Community Support Team
Community Support Team

Re: Wrong syntax for IF

Hi @A_Barny,

 

OR function is used to check multiple logical expressions and return true if one of these expressions can be achieved, I'd like to suggest you use 'in' keywords to instead.

Territory =
IF ( [Market] = "Sport" && [Region DO] IN { "CA"; "WA" }; "NorthWest"; 0 )

Regards,

Xiaoxin Sheng

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



For learning resources/Release notes, please visit: | |

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 6 members 3,391 guests
Please welcome our newest community members: