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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Sir_night
Frequent Visitor

Previous Record

With help from dearwatson i was able to identify the status changes between records 

https://community.powerbi.com/t5/Desktop/Combining-Dynamic-Query-Parameters-and-Append-Queries/m-p/2...

 

But i still need to be able to identify the previos record

 

my data looks like this , but how do i creat the prevouse record column 

 

DateRefstatusindexstatus changeprevouse  record
1/02/20171A000
2/02/20171A101
3/02/20171O211
4/02/20171G310
5/02/20171G400
6/02/20171G500
2 ACCEPTED SOLUTIONS
GilbertQ
Super User
Super User

Hi @Sir_night

 

You could create the following measure as long as you have got a Date table, which is required for the measure below.

 

To create a Date table you can follow this blog post: https://www.fourmoo.com/2016/09/13/power-bi-how-to-easily-create-dynamic-date-tabledimension-with-fi...

 

And then once that is done you can then create the following measure.

 

Measure Yesterday Rolling = 
CALCULATE (
    [Measure Name],
    LASTNONBLANK ( DATEADD ( 'Date'[Date], -1, DAY ), [Measure Name] )
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

View solution in original post

v-sihou-msft
Microsoft Employee
Microsoft Employee

@Sir_night

 

In your scenario, since you already have an index column, if you want to calculate previous record, you can create a calculated column with EARLIER to get the corresponding one:

 

previous record =
CALCULATE (
    MAX ( Table[status change] ),
    FILTER ( Table, Table[index] = EARLIER ( Table[Index] ) - 1 )
)

However, based on your data, it seems your "prevouse record" shows the next "status change", so your column might be:

 

 

=
CALCULATE (
    MAX ( Table[status change] ),
    FILTER ( Table, Table[index] = EARLIER ( Table[Index] ) + 1 )
)

Regards,

 

View solution in original post

2 REPLIES 2
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Sir_night

 

In your scenario, since you already have an index column, if you want to calculate previous record, you can create a calculated column with EARLIER to get the corresponding one:

 

previous record =
CALCULATE (
    MAX ( Table[status change] ),
    FILTER ( Table, Table[index] = EARLIER ( Table[Index] ) - 1 )
)

However, based on your data, it seems your "prevouse record" shows the next "status change", so your column might be:

 

 

=
CALCULATE (
    MAX ( Table[status change] ),
    FILTER ( Table, Table[index] = EARLIER ( Table[Index] ) + 1 )
)

Regards,

 

GilbertQ
Super User
Super User

Hi @Sir_night

 

You could create the following measure as long as you have got a Date table, which is required for the measure below.

 

To create a Date table you can follow this blog post: https://www.fourmoo.com/2016/09/13/power-bi-how-to-easily-create-dynamic-date-tabledimension-with-fi...

 

And then once that is done you can then create the following measure.

 

Measure Yesterday Rolling = 
CALCULATE (
    [Measure Name],
    LASTNONBLANK ( DATEADD ( 'Date'[Date], -1, DAY ), [Measure Name] )
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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