cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
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
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
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

Top Ideas
Users Online
Currently online: 355 members 3,472 guests
Please welcome our newest community members: