cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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:

 Year Product Category ACV 2011 A \$131,282.70 2012 A \$1,397,633.70 2013 A \$2,472,531.60 2014 A \$4,010,372.20 2015 A \$5,295,672.70 2016 A \$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
Super User

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)))``````
4 REPLIES 4
Community Support

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:

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.
Super User

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

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

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)))``````
Resolver I

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors