cancel
Showing results for
Did you mean:
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

Accepted Solutions
Super User

## Re: Create a measure with multiple If statments

@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.
)```

Super User

## Re: Create a measure with multiple If statments

@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.
)```

Announcements