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
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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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