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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
CSSR
Frequent Visitor

Calculate a difference in amount between current a previous date

Hi folks,
I have a following table in which I need to create a measure which will calculate a delta for a document (basicaly saldo) between current/selected date and date before for a document. 

CSSR_0-1719599777263.png

 

So for example, saldo for document 1b for April is 3 (calc: 15-12 ). You can see expected results in columns that are in yellow , red font. 

How did I go about this problem ? I could not use a function previousmonth because booking does not need to be in previous mont but later... so I ranked bookings for a document based on date and the latest booking is always 1 and the booking that's before is always 2 or basically by 1 more. I thought that with ranking I can get it done but i got stuck. i used following code but it did not work well:
Do you have any idea to to do it? BTW, I also have a virtual table for calendar that is connected to fact table to easily filter thru time.

 

measure = 

var a_= MAX('TABLE'[Z_Rank])
RETURN

var Prior_ =
                    CALCULATE([AMOUNT],
                               FILTER(ALLSELECTED('TABLE'),
                                           'TABLE'[Z_Rank]= a_-1)                                           
                                           )

var Current_ =
                    CALCULATE([AMOUNT],
                               FILTER(ALLSELECTED('TABLE'),'TABLE'[Z_Rank]= a_)
                                           )

RETURN
var Final_ =
(Current_- Prior_)
RETURN
DIVIDE(Final_,Final_)*Final_

 

 

thank you a lot for your suggestons and time!

much appreciated

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@CSSR , You can use visual calculation or offset  function

 

Continue to explore Power BI Offset Compare Categories, Time Intelligence MOM, QOQ, and YOY: https://youtu.be/5YMlkDNGr0U

 

Next-Level Power BI Visual Calculations with Offset, Index, Rank, RowNumber| February 2024 Update:
https://www.youtube.com/watch?v=JwMF0endTPY&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L

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

@CSSR , You can use visual calculation or offset  function

 

Continue to explore Power BI Offset Compare Categories, Time Intelligence MOM, QOQ, and YOY: https://youtu.be/5YMlkDNGr0U

 

Next-Level Power BI Visual Calculations with Offset, Index, Rank, RowNumber| February 2024 Update:
https://www.youtube.com/watch?v=JwMF0endTPY&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L

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 showing me the directon. I used offset function and all the tests that I have done so far looks promissing. 😉

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.