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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
REKLP
Helper I
Helper I

Flag the lastest row for each distinct machine

Hi Everyone, I'm trying to use a calculated column to identify which rows are the latest row for their respective serial.  The third column in the following table, is the calculated column I would like to create.

 

What I want:

SERIAL   |  DATE          | ISLATEST

SERIAL1 | JAN 1 2020 | 0

SERIAL1 | JAN 2 2020 | 1

SERIAL2 | JAN 4 2020 | 1

SERIAL2 | JAN 3 2020 | 0


=IF(v_head_shots[IgnitionTimestamp]=CALCULATE(MAX(v_head_shots[IgnitionTimestamp]),ALL(v_head_shots)),1,0)

I have attempted the following, but so far it's only identifying the latest date for the whole table.

What I'm getting:

 

SERIAL   |  DATE          | ISLATEST

SERIAL1 | JAN 1 2020 | 0

SERIAL1 | JAN 2 2020 | 0

SERIAL2 | JAN 4 2020 | 1

SERIAL2 | JAN 3 2020 | 0

 

Please help me identify what I'm doing wrong.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@REKLP , Create a new column like

if([date] = maxx(filter(table,[SERIAL]= earlier([SERIAL])),[Date]),1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@REKLP - Perhaps:

ISLATEST Column =
  VAR __Serial = [Serial]
  VAR __Date = [Date]
  VAR __Max = CALCULATE(MAX([DATE]),FILTER('Table',[SERIAL]=__Serial))
RETURN
  IF(__Date = __Max),1,0)

ISLATEST Mesure =
  VAR __Serial = MAX([Serial])
  VAR __Date = MAX([Date])
  VAR __Max = CALCULATE(MAX([DATE]),FILTER(ALL('Table'),[SERIAL]=__Serial))
RETURN
  IF(__Date = __Max),1,0)

 

You may also find this helpful: See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __Previous = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@REKLP , Create a new column like

if([date] = maxx(filter(table,[SERIAL]= earlier([SERIAL])),[Date]),1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors