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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
JamesMurg
Helper I
Helper I

IF DAX code help

Morning all, HAPPY FRIDAY!!
 
Please could someone help with the below DAX code as it will not work for me 🙂
 
Column 2 =
IF(AND(
'Report 1'[Destination ID]="IOMA",('Report 1'[Destination ID]="IOMRT", 'Report 1'[Destination ID]="UK653", 'Report 1'[Destination ID]="IOM"
"Isle of Man")
 
James
1 ACCEPTED SOLUTION
mlsx4
Super User
Super User

Hi @JamesMurg 

 

You haven't defined the correct structure for the formula. First of all, IF takes 3 parameters  (condition, what you will do if condition is met, otherwise).
On the other hand, if you want to check if Destination ID is IOMA, IOMRT, UK653 or IOM you cannot use "AND", you should use "OR". Also, the formula cannot take more than two parameters, so you will need to use "||" operator.


Therefore you should have something like:

 

 

Column 2 =
IF('Report 1'[Destination ID]="IOMA" ||'Report 1'[Destination ID]="IOMRT"|| 'Report 1'[Destination ID]="UK653"|| 'Report 1'[Destination ID]="IOM",
"Isle of Man",
<value in other case>)

 

View solution in original post

5 REPLIES 5
mlsx4
Super User
Super User

Hi @JamesMurg 

 

You haven't defined the correct structure for the formula. First of all, IF takes 3 parameters  (condition, what you will do if condition is met, otherwise).
On the other hand, if you want to check if Destination ID is IOMA, IOMRT, UK653 or IOM you cannot use "AND", you should use "OR". Also, the formula cannot take more than two parameters, so you will need to use "||" operator.


Therefore you should have something like:

 

 

Column 2 =
IF('Report 1'[Destination ID]="IOMA" ||'Report 1'[Destination ID]="IOMRT"|| 'Report 1'[Destination ID]="UK653"|| 'Report 1'[Destination ID]="IOM",
"Isle of Man",
<value in other case>)

 

@JamesMurg 

Have you checked this?

Fabrizio1
Regular Visitor

I guess you wanted to write a measure like this (even if I'm not sure that all the 4 ID described should be evaluated in an AND condition. Can they be all true at the same time?):

Column 2 =
IF(
AND(
'Report 1'[Destination ID]="IOMA",
'Report 1'[Destination ID]="IOMRT",
'Report 1'[Destination ID]="UK653",
'Report 1'[Destination ID]="IOM"),
"Isle of Man")

Fabrizio1
Regular Visitor

Hi,

it looks like it is not well formatted. you should firstly check the commas and parenthesis position.

Hi @Fabrizio1 
Could you help me put it in the correct format?

 

James

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors