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
adityakommu Member
Member

Re: Wrong syntax for IF

Yes But need to reorder things  

 

if 

Territory = if([Market] = "Sport"|| [Market] = "Profesionnal"  && ([Region DO]="CA"||[Region DO]="WA"),"NorthWest","0")

 

If your issue is resolved, please kudos and mark this as resolved.

6 REPLIES 6
A_Barny Frequent Visitor
Frequent Visitor

Need to use IF or SWITCH ?

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

adityakommu Member
Member

Re: Wrong syntax for IF

What error is it throwing?

 

 

Can you below syntax

 

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

 

A_Barny Frequent Visitor
Frequent Visitor

Re: Wrong syntax for IF

When I try to check the Syntax, it say : "DAX can't compare text type with values True/False"

adityakommu Member
Member

Re: Wrong syntax for IF

Ok try this :

 

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

A_Barny Frequent Visitor
Frequent Visitor

Re: Wrong syntax for IF

Thanks ! 

And if I want to continue this request with more IF. I can do this ? 

 

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

Thanks for your answer

Alex

Highlighted
adityakommu Member
Member

Re: Wrong syntax for IF

Yes But need to reorder things  

 

if 

Territory = if([Market] = "Sport"|| [Market] = "Profesionnal"  && ([Region DO]="CA"||[Region DO]="WA"),"NorthWest","0")

 

If your issue is resolved, please kudos and mark this as resolved.