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
ScotchCat
Regular Visitor

Need Help - Percent Change Calculation for Month to Month Trending

I need to create a Measure to show the percent of widget change from the prior month to the next.  I'll be using this to create a visual to show month to month trending.  Here is an example of what I'm looking for - the Net Change column is what I'm looking to create.  Normally I'd be looking to use the Lag function, however it doesn't seem to be available in Power BI.  Thanks in advance!

 

Month            Widgets        Net Change

Jan2019        100

Feb2019        200                     100%

Mar2019       3000               1400%

Apr2019        2500                   - 17%

May2019      1000                   -60%

Jun2019        100                      -90%

Jul2019          500                      400%

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @ScotchCat,

You can try to use the following measure formula to get the difference between current and previous amount:

measure =
VAR currDate =
    MAX ( Table[Month] )
VAR prevDate =
    CALCULATE (
        MAX ( Table[month] ),
        FILTER ( ALLSELECTED ( Table ), [Month] < currDate )
    )
VAR prevAmount =
    CALCULATE (
        SUM ( Table[Widgets] ),
        FILTER ( ALLSELECTED ( Table ), [Month] = prevDate )
    )
RETURN
    DIVIDE ( SUM ( Table[Widgets] ) - prevAmount, prevAmount )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @ScotchCat,

You can try to use the following measure formula to get the difference between current and previous amount:

measure =
VAR currDate =
    MAX ( Table[Month] )
VAR prevDate =
    CALCULATE (
        MAX ( Table[month] ),
        FILTER ( ALLSELECTED ( Table ), [Month] < currDate )
    )
VAR prevAmount =
    CALCULATE (
        SUM ( Table[Widgets] ),
        FILTER ( ALLSELECTED ( Table ), [Month] = prevDate )
    )
RETURN
    DIVIDE ( SUM ( Table[Widgets] ) - prevAmount, prevAmount )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@ScotchCat , if you have date or you can create date from month year. You can use time intelligence with date table

 

Example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
this month =MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH('Date'[Date])))
last MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
previous month value = CALCULATE(sum(''Table''[total hours value]),previousmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi


Appreciate your Kudos.

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.