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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cbtekrony
Resolver I
Resolver I

$ Difference between MIN and MAX dates

Hello, I am trying to create a card showing the difference in ACV between the MAX date and the MIN date. This is tied to a date filter on a bar graph, so when the user switches years on the graph, the card will reflect the the $ change in ACV and % change (that's for another card later) for the new range of years. So, a simple subtraction calc between the first year and last year selected is what I'm looking for for the $ change. 

However, I cannot get it to work! Here is the sample data I am working with: 

YearProduct CategoryACV
2011A$131,282.70
2012A$1,397,633.70
2013A$2,472,531.60
2014A$4,010,372.20
2015A$5,295,672.70
2016A$6,553,524.60

 I have a date table in place. Tried several things posted before but I'm not getting anywhere.  For example I'm attempting to subtract the ACV from 2012 from the ACV for 2014 to show the total change over time (so not counting 2013). I am not getting the correct value of roughly $2.6m

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@cbtekrony 

Try like

measure =
var _max = maxx('Date','Date'[Date])
var _min = Minx('Date','Date'[Date])
return
CALCULATE(SUM(Table[ACV]), FILTER(all('Date'), 'Date'[Date] =_max)) -CALCULATE(SUM(Table[ACV]), FILTER(all('Date'), 'Date'[Date] =_min))
/////////////////////////////////Or

measure =
var _max = maxx('Date','Date'[Date])
var _min = Minx('Date','Date'[Date])
return
CALCULATE(SUM(Table[ACV]), FILTER(all('Date'), year('Date'[Date]) =year(_max))) -CALCULATE(SUM(Table[ACV]), FILTER(all('Date'), year('Date'[Date]) =year(_min)))

View solution in original post

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi  @cbtekrony 

You could try the logic as below:

Measure = 
var _minyear=MIN('Table'[Year]) 
var _maxyear=MAX('Table'[Year])
return
CALCULATE(SUM('Table'[ACV]),FILTER(ALLEXCEPT('Table','Table'[Product Category]),'Table'[Year]=_maxyear))-CALCULATE(SUM('Table'[ACV]),FILTER(ALLEXCEPT('Table','Table'[Product Category]),'Table'[Year]=_minyear))
Measure 2 = 
var _minyear=MIN('Table'[Year]) 
var _maxyear=MAX('Table'[Year])
return
CALCULATE(SUM('Table'[ACV]),FILTER('Table','Table'[Year]=_maxyear))-CALCULATE(SUM('Table'[ACV]),FILTER('Table','Table'[Year]=_minyear))

 Result:

2.JPG

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

See if this works: https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/td-p/985814


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@cbtekrony 

Try like

measure =
var _max = maxx('Date','Date'[Date])
var _min = Minx('Date','Date'[Date])
return
CALCULATE(SUM(Table[ACV]), FILTER(all('Date'), 'Date'[Date] =_max)) -CALCULATE(SUM(Table[ACV]), FILTER(all('Date'), 'Date'[Date] =_min))
/////////////////////////////////Or

measure =
var _max = maxx('Date','Date'[Date])
var _min = Minx('Date','Date'[Date])
return
CALCULATE(SUM(Table[ACV]), FILTER(all('Date'), year('Date'[Date]) =year(_max))) -CALCULATE(SUM(Table[ACV]), FILTER(all('Date'), year('Date'[Date]) =year(_min)))

 
 
 @amitchandak 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.