Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
Solved! Go to Solution.
@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:
Did I answer your question ? If yes, please mark my post as a solution.
Thanks,
Jai
Proud to be a Super User! | |
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
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
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
Hi @M_SBS_6
you can write a column as follows:
@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:
Did I answer your question ? If yes, please mark my post as a solution.
Thanks,
Jai
Proud to be a Super User! | |
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 46 | |
| 42 | |
| 23 | |
| 18 |
| User | Count |
|---|---|
| 193 | |
| 123 | |
| 99 | |
| 67 | |
| 49 |