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
Ahenshaw
Frequent Visitor

Percent Change DAX calculation issue

Hello, I am new to Power BI and DAX. I am looking to calculate the percent change based on slicers that allow a user to select a starting date and end date. What I need is for the percent change to by dynamic based on the selected start date. Meaning, if you are looking at Jan 2015 through June 2015, Jan 2015 should be at 0% and then Feb would be the percent change from Feb to Jan, March to Jan, April to Jan, May to Jan, and then June to Jan. (not month to month but months displayed divided by first month selected)

 

My DAX code is below and for 90% of the data points this works but for January 2009 (my first dates in the data set) the percent change should be at 0 since it has nothing to compare to and yet they are not. Additionally, somewhere in 2019, the issue comes up again that if you filter to October 2019, the October data points should display 0% but not all do.

 

Percent (%) Change from Selected Start Date by Index = 

var minValue = CALCULATE(MIN('Index Data'[Index Value]),ALLSELECTED('Index Data'[Date]))

return

DIVIDE(FIRSTNONBLANK('Index Data'[Index Value],'Index Data'[Index Value]), minValue,0)-1

Ahenshaw_0-1634316024703.png

I also tried the below DAX to no avail. Any help to acheive the final result would be greatly appreciated. 

 I should mention, all th eindecies are on different scales and I don't want the RLB index to calculate based off Turner. They should specifically look at the value of that particular index, subtract the first value in that particular index (based on slicer date) and then divide by that first value [(current value, first value)/first value]

 

Percent (%) Change from Selected Start Date by Index = 

var minValue = CALCULATE(MIN('Sheet1'[Index Value]),ALLSELECTED('Sheet1'[Date]))

var curValue = FIRSTNONBLANK('Sheet1'[Index Value],'Sheet1'[Index Value])

var subtractValue = curValue - minValue

return

DIVIDE(subtractValue, minValue)

*I am unable to share the file itself due to it being private data but I can redact it and give a version of it if necessary.*

2 REPLIES 2
AlB
Super User
Super User

Hi @Ahenshaw 

Yes, some sample data would certainly help. Can you share a simplified, anonymized version with two indices, enought to reproduce the problem? Showing the expected result

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Ahenshaw
Frequent Visitor

@AlBHere is a link to a sample file. It's very simple in that it's just a month & Year (Date) coumn. Index Name to differentiate to Indecies we use and then the Value column. In the real data set they are all on different scales which is why I am needing to do a percent change to see a better comparison. The key is just needing this to be dynamic so if they select the Start Date of Jan 2010 (even though the data starts in Jan 2009) that the percent change in June 2010 is calculated from Jan 2010 (not the first data point)

 

Link to Sample Data 

 

In this example data, Jan 2009 % change for both indecies should be 0% since there was no change from that starting point, however - if you were looking at Jan & Feb 2009:

The Turner Index increased by 10% ((1.10-1.0)/1.0)

The RLB Index increased by 16% ((1.45-1.25)/1.25)

 

Let me know if additional direction/information is needed. Thanks

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.

Top Solution Authors