cancel
Showing results for
Did you mean:
Highlighted
New Member

## Calculate Difference Between 2 Values Same Column - Based on Date Filters

Hi all,

Relatively new Power BI user here.  I have one column that has account \$ values and another column that has dates.  When I bring the data into a matrix table I can filter the columns by particular dates and have rows by sales rep, but now I would like to calculate the difference in \$ amounts and calculate the % difference between any 2 dates that I select.  I know how to do this in Excel, but am completely unsure how to approach this in Power BI.

For example,

03/26/20           04/02/20           Difference         % Difference

John    \$1,987,123        \$2,345,961               ?                    ?

Steve   \$3,987,123         \$5,345,961              ?                    ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted Super User IV

## Re: Calculate Difference Between 2 Values Same Column - Based on Date Filters

Assumed you have joined with a date dimension and want to slicer min and max date. For static change the variable(Var) values

``````difference =
var _max = maxx('Date','Date'[Date])
var _min = Minx('Date','Date'[Date])

return
CALCULATE(SUM(Table[values ]), FILTER(all('Date'), 'Date'[Date] =_max)) -CALCULATE(SUM(Table[values ]), FILTER(all('Date'), 'Date'[Date] =_min))

difference =
var _max = maxx('Date','Date'[Date])
var _min = Minx('Date','Date'[Date])

return
divide(SUM(Table[values ]), FILTER(all('Date'), 'Date'[Date] =_max)) ,CALCULATE(SUM(Table[values ]), FILTER(all('Date'), 'Date'[Date] =_min))) -1``````

In case you need two slicer, refer to my blog :https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

3 REPLIES 3
Highlighted Super User IV

## Re: Calculate Difference Between 2 Values Same Column - Based on Date Filters

---------------------------------------

Putting square pegs in round holes since 1972.

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Super User!

Highlighted Super User IV

## Re: Calculate Difference Between 2 Values Same Column - Based on Date Filters

Hi,

1. Will you always only select 2 dates?
2. Will the 2 selected dates always be continuous?
3. Share data in format that can be pasted in MS Excel.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Highlighted Super User IV

## Re: Calculate Difference Between 2 Values Same Column - Based on Date Filters

Assumed you have joined with a date dimension and want to slicer min and max date. For static change the variable(Var) values

``````difference =
var _max = maxx('Date','Date'[Date])
var _min = Minx('Date','Date'[Date])

return
CALCULATE(SUM(Table[values ]), FILTER(all('Date'), 'Date'[Date] =_max)) -CALCULATE(SUM(Table[values ]), FILTER(all('Date'), 'Date'[Date] =_min))

difference =
var _max = maxx('Date','Date'[Date])
var _min = Minx('Date','Date'[Date])

return
divide(SUM(Table[values ]), FILTER(all('Date'), 'Date'[Date] =_max)) ,CALCULATE(SUM(Table[values ]), FILTER(all('Date'), 'Date'[Date] =_min))) -1``````

In case you need two slicer, refer to my blog :https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Announcements #### Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members. #### Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start. #### Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications #### Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021 Top Solution Authors
Top Kudoed Authors
Users online (685)