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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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)

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@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


@ 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!:
Mastering Power BI 2nd Edition

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)

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors