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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
planning
Frequent Visitor

Conditional formatting

Hi all,

 

I have a table like this:

 

Boat          Date         Status

A         15/07/2020       2

A         16/07/2020       1

A         17/07/2020       2

B         15/07/2020       1

B         16/07/2020       2

B         17/07/2020       1

 

How can I add a new calculated column showing in each row the status of the same boat in the previous day, showing as follows:

 

Boat          Date         Status     Status Day Before

A         15/07/2020       2                       -

A         16/07/2020       1                      2

A         17/07/2020       2                      1

B         15/07/2020       1                       -

B         16/07/2020       2                      1

B         17/07/2020       1                      2

 

Thanks!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@planning - Try:

 

Status Day Before =
  VAR __DayBefore = MAXX(FILTER('Table',[Date] = EARLIER('Table'[Date]) - 1 && [Boat] = EARLIER('Table'[Boat])),[Status])
RETURN
  __DayBefore

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@planning - Try:

 

Status Day Before =
  VAR __DayBefore = MAXX(FILTER('Table',[Date] = EARLIER('Table'[Date]) - 1 && [Boat] = EARLIER('Table'[Boat])),[Status])
RETURN
  __DayBefore

@ 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!:
The Definitive Guide to Power Query (M)

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

@planning , As new column

//continous day

Last day value = maxx(filter(Table, [date] = earlier([date]) -1 && [Boat] = earlier([Boat])),[Status])

 

// noncontinous day

Last day value =
var _max = maxx(filter(Table, [date] < earlier([date]) && [Boat] = earlier([Boat])),[date])
return
maxx(filter(Table, [date] = _max && [Boat] = earlier([Boat])),[Status])

 

for measure for same case find measure here

https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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