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
wdbirch19
New Member

Plotting difference in value between two date ranges

Hi PowerBI community!

 

I've been going round in circles for a couple of days trying to figure this one out so I decided to reach out for some help.

 

I'm working with some time series data (example below - my real data is a bit more complex) and want to be able to plot the difference between the first and last value for a given day range. However, I want this value to be on a bar chart that is updated depending on a filter that is on the page. 

 

For example for the data below if I am sepecting the range Day 1 > Day 4 then the value would be 5.7-1.5=4.2; if I am selecting the range Day 3 > Day 5 then it would be 3.2-1.7=1.5.

 

DayValue
11.5
22.4
31.7
45.7
53.2
6

4.8

7

5.3

86.9

 

I can easily calculate a difference in DAX between each value and the value on Day 0, but this doesn't update with filters etc. 

 

Any help with this would be hugely appreciated!

1 ACCEPTED SOLUTION
gmsamborn
Super User
Super User

Hi @wdbirch19 

 

Would something like this help?

 

zMeasure = 
VAR _StartDate = MIN( 'Table1'[Date] )
VAR _EndDate = MAX( 'Table1'[Date] )
VAR _StartVal = 
    CALCULATE(
        MAX( 'Table1'[Value] ),
        'Table1'[Date] = _StartDate
    )
VAR _EndVal = 
    CALCULATE(
        MAX( 'Table1'[Value] ),
        'Table1'[Date] = _EndDate
    )
VAR _Diff = _EndVal - _StartVal
RETURN
    _Diff

OR

zMeasure 2 = 
CALCULATE(
    MAX( 'Table1'[Value] ),
    'Table1'[Date] = MAX( 'Table1'[Date] )
)
-
CALCULATE(
    MAX( 'Table1'[Value] ),
    'Table1'[Date] = MIN( 'Table1'[Date] )
)

 

 

I hope this helps.



Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

2 REPLIES 2
wdbirch19
New Member

Hi @gmsamborn, thank you for your help! That works great 😁 Much appreciated

gmsamborn
Super User
Super User

Hi @wdbirch19 

 

Would something like this help?

 

zMeasure = 
VAR _StartDate = MIN( 'Table1'[Date] )
VAR _EndDate = MAX( 'Table1'[Date] )
VAR _StartVal = 
    CALCULATE(
        MAX( 'Table1'[Value] ),
        'Table1'[Date] = _StartDate
    )
VAR _EndVal = 
    CALCULATE(
        MAX( 'Table1'[Value] ),
        'Table1'[Date] = _EndDate
    )
VAR _Diff = _EndVal - _StartVal
RETURN
    _Diff

OR

zMeasure 2 = 
CALCULATE(
    MAX( 'Table1'[Value] ),
    'Table1'[Date] = MAX( 'Table1'[Date] )
)
-
CALCULATE(
    MAX( 'Table1'[Value] ),
    'Table1'[Date] = MIN( 'Table1'[Date] )
)

 

 

I hope this helps.



Proud to be a Super User!

daxformatter.com makes life EASIER!

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.