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
datajunkie_29
Helper I
Helper I

DAX dynamic Percent change based on Calendar slicer.

Hello all,

 

I'm trying to write a measure that calculates % change (MoM) based on the Date slicer. And the start date % change must show 0 irrespective of data.

 

Currently, this is how the visual is displayed:

datajunkie_29_0-1683853785859.png

 

DAX measures:

1. Prior Month Price Per Unit $ = CALCULATE([Net Price Per Unit], PREVIOUSMONTH('Calendar'[Date]))  

 

2. Average Price Change % = DIVIDE([Net Price Per Unit] - [Prior Month Price Per Unit $] , [Prior Month Price Per Unit $] )

 

3. Price Change % = CALCULATE([Average Price Change %], PREVIOUSMONTH('Calendar'[Date])) + [Average Price Change %]

 

How can I show Jan/or any starting month as 0 and then MoM calc based on the start date and end date selected from the slicer.

 

Any help is appreciated! Thank you
 
1 ACCEPTED SOLUTION

Hello @FreemanZ , 

 

The above solution worked for me, after changing MAX to MIN in the return function. I guess there was a typo in the above code.

NewMeasure =
VAR _startdate =
CALCULATE(
    MIN('Calendar'[Date]),
    ALLSELECTED('Calendar')
)
RETURN
IF(
    MIN('Calendar'[Date]))=_startdate,
    0,
    [Price Change %]
)

Thank you for your help! Appreciate it 🙂  

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

hi @datajunkie_29

NewMeasure =
VAR _startdate =
CALCULATE(
    MIN('Calendar'[Date]),
    ALLSELECTED('Calendar')
)
RETURN
IF(
    MAX('Calendar'[Date]))=_startdate,
    0,
    [Price Change %]
)

Hello @FreemanZ , 

 

The above solution worked for me, after changing MAX to MIN in the return function. I guess there was a typo in the above code.

NewMeasure =
VAR _startdate =
CALCULATE(
    MIN('Calendar'[Date]),
    ALLSELECTED('Calendar')
)
RETURN
IF(
    MIN('Calendar'[Date]))=_startdate,
    0,
    [Price Change %]
)

Thank you for your help! Appreciate it 🙂  

Hello @FreemanZ ,

 

Thank you for your response. I tried the above measure and unfortunately, the start month still shows percent change number (attached below)

 

datajunkie_29_0-1683901063755.png

 

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.