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
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))

 

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))

 

@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
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.