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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Akkoustic
Frequent Visitor

Create a measure with multiple If statments

I'm very new to DAX and would like to know how to create a certain measure. I would like to create a DAX measure to allow me to format the Status field result ‘Open’ according to the number of days to Completion Dax Measure with a lot of IF statement. 

Logic:

If Status = Open, AND Days to Completion <0, THEN CompletionStatus = -1 

If Status = Open, AND Days to Completion is between 0 (included) and less than 7 days, THEN CompletionStatus = 1

If Status = Open, AND Days to Completion is greater than 7 days, THEN CompletionStatus = 2 

If Status = Completed, THEN CompletionStatus= 0

If Status = Cancelled, THEN CompletionStatus= 3

 

Is this even possible by doing this in one measure? Is there a better practise I could try?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Akkoustic  - The SWITCH function is ideal for multiple IFs. Example:

CompletionStatus  = 
SWITCH(
TRUE(),
   Status = "Open" && Days to Completion <0,  -1,
   Status = "Open" && Days to Completion >=0 && Days to Completion < 7, 1,
   etc.
)

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

@Akkoustic  - The SWITCH function is ideal for multiple IFs. Example:

CompletionStatus  = 
SWITCH(
TRUE(),
   Status = "Open" && Days to Completion <0,  -1,
   Status = "Open" && Days to Completion >=0 && Days to Completion < 7, 1,
   etc.
)

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.