cancel
Showing results for
Did you mean:
Helper I

## DAX help - Calculated boolean column with latest value of each ID

Hi!

I have a dataset that looks like this:

C_ID     DATE

1           01/01/2022

2           02/01/2022

2           03/01/2022

3           04/01/2022

4           06/01/2022

4           05/01/2022

I need to create a calculated column that shows true if it's the latest of each ID, like this:

C_ID     DATE                   isTheLatestOfId

1           01/01/2022        True

2           02/01/2022        False

2           03/01/2022        True

3           04/01/2022        True

4           06/01/2022        True

4           05/01/2022        False

Is there a way I can do this with DAX?

So far I managed to obtain the latest of all of them like this:

isTheLatestOfId= IF(CALCULATE(MAX(T1[Date]))=MAX(T1[Date]),TRUE,FALSE)

But it only sets to true the one with date "06/08/2022 13:50".

1 ACCEPTED SOLUTION
Community Support

Hi @Fátima

You can refer to the following example.

You can create a column:

``````isTheLatestOfId = var _filter=FILTER('Table',[C _ID]=EARLIER('Table'[C _ID]))
return if([DATE]=MAXX(_filter,[DATE]),TRUE(),FALSE())``````

Or you can create it as a measure:

``````Measure = var _filter=FILTER(ALL('Table'),[C _ID]=MAX('Table'[C _ID]))
return IF(MAX([DATE])=MAXX(_filter,[DATE]),TRUE(),FALSE())``````

Output:

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 REPLIES 3
Helper I

Thank you @v-xinruzhu-msft and @olgad !

Since the answer by @v-xinruzhu-msft allows me to not create an additional column, I'll mark that one as the accepted solution.

Regards!

Community Support

Hi @Fátima

You can refer to the following example.

You can create a column:

``````isTheLatestOfId = var _filter=FILTER('Table',[C _ID]=EARLIER('Table'[C _ID]))
return if([DATE]=MAXX(_filter,[DATE]),TRUE(),FALSE())``````

Or you can create it as a measure:

``````Measure = var _filter=FILTER(ALL('Table'),[C _ID]=MAX('Table'[C _ID]))
return IF(MAX([DATE])=MAXX(_filter,[DATE]),TRUE(),FALSE())``````

Output:

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Power Participant

Hi Fatima,
not dax, but may be you can use it.
In Power query go transform group by

Hope that helps you!

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

#### Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors