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! Request now

Reply
mkoontz
Frequent Visitor

Get value from previous record based on Period

I have a table that is by Contract, Period (YYYYMM). I have a measure that is grabbing the previous record based on the Period column. This works great when the previous record is in the same year, but when I go from 202101 to 202012, my measure will not work. I am looking for some guidance on the best approach to grab previous record when it switches years based on my Period column.

 

Previous Value =
    CALCULATE( [measure for column ($)],
        FILTER( ALL( dimDate ),
        dimDate[Period] = SELECTEDVALUE( dimDate[Period] ) - 1
    )
)
ex. 202101 - 1 ( will not get me the 202012 I am looking for). 
 
Any help would be greatly appreciated. Thanks in advance. I will continue looking on my end.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@mkoontz , Create a rank on YYYYMM in you date table.

a new column

Period Rank = RANKX(all('Date'),'Period'[year period],,ASC,Dense)

 

try measures like these examples 


This Period = CALCULATE( [measure for column ($)], FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])))
Last Period = CALCULATE( [measure for column ($)], FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])-1))

 

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
amitchandak
Super User
Super User

@mkoontz , Create a rank on YYYYMM in you date table.

a new column

Period Rank = RANKX(all('Date'),'Period'[year period],,ASC,Dense)

 

try measures like these examples 


This Period = CALCULATE( [measure for column ($)], FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])))
Last Period = CALCULATE( [measure for column ($)], FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])-1))

 

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

@amitchandak Thank you for the quick reply. Greatly appreciated. Your solution worked great for me.

mkoontz_0-1611766628326.png

Thank you again.

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