cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
Community Champion
Community Champion

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

Is this school homework? 😀😀😀

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors