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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
powerbiexpert22
Impactful Individual
Impactful Individual

dynamic running difference

I want to calculate the difference between current value and previous value dynamically based on date hierarchy , how to acheive same in power bi?

Example 

Scenario 1:  if i use year and sales then below should be the output 

powerbiexpert22_0-1709136431325.png

Scenario 2:  if i use year, month and sales, then below should be the output 

 

powerbiexpert22_1-1709136550005.png

 

2 REPLIES 2
amitchandak
Super User
Super User

@powerbiexpert22 , We got visual calculation function in Feb release. Try previous

 

Master Visual Calculations in Power BI- February 2024 Update RUNNINGSUM, RANGE, MOVINGAVERAGE, COLLAPSE, COLLAPSEALL, EXPAND, EXPANDALL, FIRST, LAST, PREVIOUS, and NEXT
https://www.youtube.com/watch?v=bKD9T0EWgQo&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L

 

Release Notes: https://powerbi.microsoft.com/en-us/blog/visual-calculations-preview/
Microsoft Documentation: https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-visual-calculations-overview

 

 

Or checkout offset

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

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

Hi @amitchandak ,

 

we cannot use visual calculations since it is in preview mode, I am able to calculate previous sales with below logic however if i sort the month then previous value is showing blank for month 

 

Level = SWITCH(
TRUE(),
ISINSCOPE('CALENDAR'[Month]),"Month",
ISINSCOPE('CALENDAR'[Year]),"Year"
,"All"
)

Previous Sales

Prev Sales =
IF(
 [Level]="Year" ,  
CALCULATE([Sales],OFFSET(-1,All('CALENDAR'[Year]))),
IF(
     [Level]="Month",
CALCULATE([Sales],OFFSET(-1,All('CALENDAR'[Month]))
)))
 
powerbiexpert22_0-1709199534290.png

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors