cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rena
Helper III
Helper III

Identify and display changes in data between month m and m-1

Hello,

I have an excel file which contains the different products ordored by a company every month. See the table below :

Rena_3-1652224435391.png

 I would like to display in May the changes that have occurred on the products ordered compared to April. 

Example :

 

Rena_2-1652224324492.png

Or

 

Rena_4-1652224467522.png

 

Can somebody help me do this please?

 

Best regards,

 

Rena.

1 ACCEPTED SOLUTION

Hi @Rena ,

 

Sorry for reply late, one parameter error occurs in your code.

vchenwuzmsft_0-1653446418441.png

And add one more filter in this expression via ALL('Data-Products').

 

ColorChanges = 
var _c = CALCULATE(MAX('Data-Products'[Color]),PREVIOUSMONTH('Data-Products'[Month]),ALL('Data-Products'))
return
IF(not(ISBLANK(_c)) && _c<>MAX('Data-Products'[Color]),MAX('Data-Products'[Color]))

 

I have modefiy your pbix in the attachment.

 

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

9 REPLIES 9
v-chenwuz-msft
Community Support
Community Support

Hi @Rena ,

 

You can do that by creating two measure, one named new color and another new stock.

New Color =
VAR _c =
    CALCULATE ( MAX ( 'Table'[Color] ), PREVIOUSMONTH ( 'Table'[Month] ) )
RETURN
    IF (
        NOT ( ISBLANK ( _c ) )
            && _c <> MAX ( 'Table'[Color] ),
        MAX ( 'Table'[Color] )
    )


New Stock =
VAR _s =
    CALCULATE ( MAX ( 'Table'[Stock] ), PREVIOUSMONTH ( 'Table'[Month] ) )
RETURN
    IF (
        NOT ( ISBLANK ( _s ) )
            && _s <> MAX ( 'Table'[Stock] ),
        MAX ( 'Table'[Stock] )
    )

Result:

vchenwuzmsft_0-1652433024599.png

 

If you want get the result dynamicly by slicer. Try this:

Measure =
VAR _select =
    SELECTEDVALUE ( 'Slicer'[Compare] )
VAR _color =
    CALCULATE ( MAX ( 'Table'[Color] ), PREVIOUSMONTH ( 'Table'[Month] ) )
VAR _stock =
    CALCULATE ( MAX ( 'Table'[Stock] ), PREVIOUSMONTH ( 'Table'[Month] ) )
VAR _switch_result =
    SWITCH ( _select, "Color", MAX ( 'Table'[Color] ), MAX ( 'Table'[Stock] ) )
VAR _map_column =
    SWITCH (
        _select,
        "Color",
            _color <> MAX ( 'Table'[Color] )
                && NOT ( ISBLANK ( _color ) ),
        _stock <> MAX ( 'Table'[Stock] )
            && NOT ( ISBLANK ( _stock ) )
    )
RETURN
    IF ( _map_column, _switch_result )

Result:

vchenwuzmsft_1-1652433339581.gif

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.

Hello,

Thanks for the response but it does not work for me. I have this error : 

 

Rena_0-1652718635864.png

It says that column specified in the "PREVIOUSMONTH" function is not date type i don't understand why

Hi @Rena ,

 

The type of this [Month] should be date. For example, 2022-05, you can change it to 2022-05-01, and format it as "yyyy-mm".

vchenwuzmsft_1-1652751550288.png

 

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.

My Month Column is already the date type that's why i don't understand the error.

Rena_0-1652880266253.png

 

Hi @Rena ,

 

Please share your pbix file without sensitive data and i will help you to fix it.

 

Best Regards

Community Support Team _ chenwu zhu

Hello,

 

Here is the link to the .pbix file cause i don't have the option to attach a file here.

 

https://drive.google.com/file/d/1OpNhaRSYJHVLzFYFwgdz_UgqAkSCFpzt/view?usp=sharing

 

Best regards,

Hi @Rena ,

 

Sorry for reply late, one parameter error occurs in your code.

vchenwuzmsft_0-1653446418441.png

And add one more filter in this expression via ALL('Data-Products').

 

ColorChanges = 
var _c = CALCULATE(MAX('Data-Products'[Color]),PREVIOUSMONTH('Data-Products'[Month]),ALL('Data-Products'))
return
IF(not(ISBLANK(_c)) && _c<>MAX('Data-Products'[Color]),MAX('Data-Products'[Color]))

 

I have modefiy your pbix in the attachment.

 

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.

 

Hello,

Thank you so much.

It works.

Best regards,

 

speedramps
Super User
Super User

A few people have asked the same question tonight with almost the same data. 

Is this school homework? 😀😀😀

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors