cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

## DAX formula for if then else

Hi - I'm new to DAX and would like some guidance to write something for a new measure:

Trying to come with a calculation

(If selected month is January then use January Measure

Else

Regular measure)

1 ACCEPTED SOLUTION

Accepted Solutions
Established Member

## Re: DAX formula for if then else

Hi there - this question is probably better being asked in the Desktop forum rather than Developer, as a lot more DAX experts frequent that particular forum and could help you faster than in here.

That being said, it should be a case of the following, assuming:

• You have a measure called [January Measure] for the IF statement
• You have a measure called [Regular Measure] for the else portion
• You have a date table named Date and we're using the [Month] column to evaluate for a value of "January"
• You're including the above column in the visual you're using
• We'll call the measure [Conditional Measure]

Syntax would be as follows:

```[Conditional Measure] =
IF(
SELECTEDVALUE('Date'[Month]) = "January",
[January Measure],
[Regular Measure]
)```

It should be a case of swapping these out with your fields and measures as necessary.

Here's some further reading on SELECTEDVALUE (the SQLBI guys are pretty much essential reading for anyone who wants to learn DAX - you should make dax.guide a regular place to visit if you haven't already )

Good luck!

2 REPLIES 2
Established Member

## Re: DAX formula for if then else

Hi there - this question is probably better being asked in the Desktop forum rather than Developer, as a lot more DAX experts frequent that particular forum and could help you faster than in here.

That being said, it should be a case of the following, assuming:

• You have a measure called [January Measure] for the IF statement
• You have a measure called [Regular Measure] for the else portion
• You have a date table named Date and we're using the [Month] column to evaluate for a value of "January"
• You're including the above column in the visual you're using
• We'll call the measure [Conditional Measure]

Syntax would be as follows:

```[Conditional Measure] =
IF(
SELECTEDVALUE('Date'[Month]) = "January",
[January Measure],
[Regular Measure]
)```

It should be a case of swapping these out with your fields and measures as necessary.

Here's some further reading on SELECTEDVALUE (the SQLBI guys are pretty much essential reading for anyone who wants to learn DAX - you should make dax.guide a regular place to visit if you haven't already )

Good luck!

Frequent Visitor

## Re: DAX formula for if then else

Thank you! that worked. Will post these kind of questions under Desktop forum from now on.

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 59 members 1,080 guests
Recent signins: