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

#### New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

#### Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

#### Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)