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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
M_SBS_6
Helper V
Helper V

Latest Date by Column Value

Hi, 

 

I have several columns in my table and I'd like to flag a 1 or 0 in another column based on the latest date by product. Any idea how to do this please? 

ID.  Date.         Product.   Flag

1.   11/01/23.     AD.           0

2.   11/01/23.     AD.           0

3.    06/08/24.   AD.            1

2 ACCEPTED SOLUTIONS
Jai-Rathinavel
Super User
Super User

@M_SBS_6 Create a calculated column using the below DAX

 

 

Flag = 
var maxdate = CALCULATE(MAX(MyTable[Date]) , ALLEXCEPT(MyTable,MyTable[Product]))
RETURN
IF( MyTable[Date] = maxdate , 1 , 0 )

 

 

Output:

JaiRathinavel_0-1732538498764.png

 

Did I answer your question ? If yes, please mark my post as a solution.

 

Thanks,

Jai




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Kedar_Pande
Super User
Super User

@M_SBS_6 

New column:

Flag = 
VAR LatestDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
'Table',
'Table'[Product] = EARLIER('Table'[Product])
)
)
RETURN
IF('Table'[Date] = LatestDate, 1, 0)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @M_SBS_6 ,

Thanks for all the replies!
Please check to see if these replies can help you. If solved please accept the reply in this post which you think is helpful as a solution to help more others facing the same problem to find a solution quickly, thank you very much!

Best Regards,
Dino Tao

Kedar_Pande
Super User
Super User

@M_SBS_6 

New column:

Flag = 
VAR LatestDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
'Table',
'Table'[Product] = EARLIER('Table'[Product])
)
)
RETURN
IF('Table'[Date] = LatestDate, 1, 0)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Selva-Salimi
Super User
Super User

Hi @M_SBS_6 

 

you can write a column as follows:

Column = var max_date = calculate(max('Table'[Date]) , filter('Table' , 'Table'[Product]=EARLIER('Table'[Product])))
return
if (max_date='Table'[Date] , 1 ,0)
 
If this post helps, then I would appreciate a thumbs up 👍and mark it as the solution to help the other members find it more quickly.
Jai-Rathinavel
Super User
Super User

@M_SBS_6 Create a calculated column using the below DAX

 

 

Flag = 
var maxdate = CALCULATE(MAX(MyTable[Date]) , ALLEXCEPT(MyTable,MyTable[Product]))
RETURN
IF( MyTable[Date] = maxdate , 1 , 0 )

 

 

Output:

JaiRathinavel_0-1732538498764.png

 

Did I answer your question ? If yes, please mark my post as a solution.

 

Thanks,

Jai




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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