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
kevinko14
Regular Visitor

Calculate variance from previous date

Hi,

 

I have a table as below, so I would like to find out the production variance between 2 different reportdate. How can I do this in Power BI?

 

kevinko14_0-1637306232937.png

 

I created pivot table as example

kevinko14_1-1637306273067.png

 

I would like the end reuslt is like below.

Example:

Variance between reportdate 25/10/2021 and 26/10/2021 is 22-6=16

then variance between reportdate 26/10/2021 and 27/10/2021 is 23-22=1

kevinko14_2-1637306298922.png

 

This is what I created in PowerBI.

kevinko14_3-1637306334783.png

 

Thank you so much for your help.

 

Regards,

Kevin

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @kevinko14 

Based on this example, the solution is 

vxiaotang_0-1637654886499.png

create the measures,

Measure = 
    var _predate=CALCULATE(MAX('Table'[ReportDate]),FILTER(ALL('Table'),'Table'[ReportDate]<MAX('Table'[ReportDate])))
    var _prevalue=CALCULATE(SUM('Table'[Production]),FILTER(ALL('Table'),'Table'[ReportDate]=_predate&&'Table'[Date]=MAX('Table'[Date])))
return IF(ISBLANK(_predate),0,SUM('Table'[Production])-_prevalue)

result

vxiaotang_1-1637654967446.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @kevinko14 

Based on this example, the solution is 

vxiaotang_0-1637654886499.png

create the measures,

Measure = 
    var _predate=CALCULATE(MAX('Table'[ReportDate]),FILTER(ALL('Table'),'Table'[ReportDate]<MAX('Table'[ReportDate])))
    var _prevalue=CALCULATE(SUM('Table'[Production]),FILTER(ALL('Table'),'Table'[ReportDate]=_predate&&'Table'[Date]=MAX('Table'[Date])))
return IF(ISBLANK(_predate),0,SUM('Table'[Production])-_prevalue)

result

vxiaotang_1-1637654967446.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

@v-xiaotang It works, thank you so much.

amitchandak
Super User
Super User

@kevinko14 , refer if this can help

 

How to use two Date/Period slicers :https://www.youtube.com/watch?v=WSeZr_-MiTg

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

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 

Thanks for your video. Sorry that I confused you, I would like to find out variance of production from two different dates 

for example:

 

Cell B19 is variance between 25/10/2021 and 26/10/2021, formula B6-B5=22-6=16

Cell B20 is variance between 26/10/2021 and 27/10/2021, formula B7-B6=23-22=1

 

How can I do this in powerbi?

kevinko14_0-1637314136742.png

 

Thank you so much.

 

Kevin

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.