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
agy2
Frequent Visitor

Adding column to show last month's value

Hi everyone,

 

I am currently using a table similar to the one below, but with significantly more rows (data going back 18 months for several thousand accounts). Rows are added for each account at the end of each month with an end of month value for X.

 

AccountIDDateX
131/08/20170
231/08/20170
331/08/20170
431/08/20170
130/09/20170
230/09/20172
330/09/20173
430/09/20171
131/10/20171
231/10/20172
331/10/20172
431/10/20172
531/10/20170

 

What I am trying to create is a column as in the table below, which shows the value of X for each account at the end of the previous month, however cannot get the correct value. If I simply calculate X for the previous month, blank values are returned as there is nothing in my calculation to tell Power BI to link the rows by account ID. Any help would be great, thanks!

 

AccountIDDateXPrevious X
131/08/20170 
231/08/20170 
331/08/20170 
431/08/20170 
130/09/201700
230/09/201720
330/09/201730
430/09/201710
131/10/201710
231/10/201722
331/10/201723
431/10/201721
531/10/20170 
1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @agy2

 

Try this calculated Column

 

Previous X =
CALCULATE (
    VALUES ( Table1[X] ),
    ALLEXCEPT ( Table1, Table1[AccountID] ),
    PREVIOUSMONTH ( Table1[Date] )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

Hi @agy2

 

Try this calculated Column

 

Previous X =
CALCULATE (
    VALUES ( Table1[X] ),
    ALLEXCEPT ( Table1, Table1[AccountID] ),
    PREVIOUSMONTH ( Table1[Date] )
)

Regards
Zubair

Please try my custom visuals

Hi @Zubair_Muhammad,

 

This works perfectly, thanks for your help!

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.