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
Anonymous
Not applicable

DAX - Difference between min and max year

Hello Power BI community,

 

I need help coming up with a DAX formula to calculate the difference between the minimum (lowest selected) fiscal year and the maximum (highest selected) fiscal year.

To summarize, I would like to subtract the lowest selected fiscal year from the highest selected fiscal year. In the screencapture below, the rate should read as -1% (4% in 2017/2018 MINUS 5% in 2014/2015) .Capture.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

Here is what I have so far:

Min and Max Year Rate Change =

CALCULATE(

 SUM('Master'[Rate]),

 FILTER('Master','Master'[Fiscal Year]=MAX('Master'[Fiscal Year])

 )

 ),

-

 CALCULATE(

 SUM('Master'[Rate]),

 FILTER('Master','Master'[Fiscal Year]=MIN('Master'[Fiscal Year])))

,0)

 

The expression above yields the following error message:

To use special characters in a measure name, enclose the entire name in brackets ( [] ) and add a ] to any closing brackets in the name.

 

Sample workbook with altered data below for reference:

Fiscal YearRate
2006/20079.1%
2007/20085.6%
2008/20093.7%
2009/201016.9%
2010/201116.4%
2011/201215.3%
2012/20138.9%
2013/20148.9%
2014/20154.6%
2015/201616.7%
2016/201715.1%
2017/20182.1%
2018/201910.6%

 

Any help on the matter would be greatly appreciated 🙂 thank you!

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Didn't dig into what is potentially wrong with your formula, and I got a positive 2.5 with the data you supplied. 4.6 - 2.1

 

Measure 2 = 
VAR __max = MAX('Table5'[Fiscal Year])
VAR __min = MIN('Table5'[Fiscal Year])
RETURN
SUMX(FILTER('Table5',[Fiscal Year]=__min),[Rate]) - SUMX(FILTER('Table5',[Fiscal Year]=__max),[Rate])

@ 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...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Didn't dig into what is potentially wrong with your formula, and I got a positive 2.5 with the data you supplied. 4.6 - 2.1

 

Measure 2 = 
VAR __max = MAX('Table5'[Fiscal Year])
VAR __min = MIN('Table5'[Fiscal Year])
RETURN
SUMX(FILTER('Table5',[Fiscal Year]=__min),[Rate]) - SUMX(FILTER('Table5',[Fiscal Year]=__max),[Rate])

@ 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...
Anonymous
Not applicable

Thank you so much! This works well for me.

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.