Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Fidzi8
Helper IV
Helper IV

month to month % difference

Hi,
I need help.
How I calculate new measure for month to month % difference?
2022-02-04_09h39_32.png

 

Thank you
Ondřej

1 ACCEPTED SOLUTION

Hi @Fidzi8 ,

 

Maybe you can use HASONEVALUE() to control the total row.

Some code like the following:

Diff =
VAR _last =
    CALCULATE(
        SUM( 'Table'[Cost] ),
        DATESMTD( DATEADD( 'Table'[Month], -1, MONTH ) )
    )
VAR _diff =
    DIVIDE ( SUM( 'Table'[Cost] ) - _last , _last)
VAR _maxmonth =
    CALCULATE(
        SUM( 'Table'[Cost] ),
        MONTH( 'Table'[Month] ) = MONTH( MAX( 'Table'[Month] ) )
    )
VAR _maxmonth_1 =
    CALCULATE(
        SUM( 'Table'[Cost] ),
        MONTH( 'Table'[Month] )
            = MONTH( MAX( 'Table'[Month] ) ) - 1
    )
RETURN
    IF(
        HASONEVALUE( 'Table'[Month] ),
        _diff,
        DIVIDE( _maxmonth - _maxmonth_1, _maxmonth_1 )
    )

Result:

vchenwuzmsft_0-1644476311098.png

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Fidzi8 , we can use time intelligence for month on month

 

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]))

 

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

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

Thank you @amitchandak 

I create your measures and the sub-part works but the overall result is bad.

 

Fidzi8_0-1643976237522.png

 

How can I adjust the measures to work.

Thank you
Ondřej

 

 

Hi @Fidzi8 ,

 

Maybe you can use HASONEVALUE() to control the total row.

Some code like the following:

Diff =
VAR _last =
    CALCULATE(
        SUM( 'Table'[Cost] ),
        DATESMTD( DATEADD( 'Table'[Month], -1, MONTH ) )
    )
VAR _diff =
    DIVIDE ( SUM( 'Table'[Cost] ) - _last , _last)
VAR _maxmonth =
    CALCULATE(
        SUM( 'Table'[Cost] ),
        MONTH( 'Table'[Month] ) = MONTH( MAX( 'Table'[Month] ) )
    )
VAR _maxmonth_1 =
    CALCULATE(
        SUM( 'Table'[Cost] ),
        MONTH( 'Table'[Month] )
            = MONTH( MAX( 'Table'[Month] ) ) - 1
    )
RETURN
    IF(
        HASONEVALUE( 'Table'[Month] ),
        _diff,
        DIVIDE( _maxmonth - _maxmonth_1, _maxmonth_1 )
    )

Result:

vchenwuzmsft_0-1644476311098.png

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Europe Fabric Conference

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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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