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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
VDebande
New Member

Comparing value to previous Column in matrix

Dear all, 

 

I have a matrix that allows me to see the evolution of sales for my products over time. 

 

I would like to highlight the value when it's X% greater or lower than the value of the week before (or, in next step, the mean of the sales for all weeks ?). 

 

See the first matrix as the data I have in Power BI. 

The second would be the difference with the week before. 

 

VDebande_0-1704479136119.png

 

How could I achieve this ? 

Thanks a lot !

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @VDebande ,

Please try:

Diff =
IF (
    SELECTEDVALUE ( 'Date'[Week] ) = 1,
    0,
    [YourMeasure]
        - CALCULATE (
            [Total Profit],
            'Date'[Week]
                = SELECTEDVALUE ( 'Date'[Week] ) - 1
        )
)

vcgaomsft_0-1704787760454.png

Diff% = 
VAR _cur_week = [Total Profit]
VAR _pre_week = CALCULATE([YourMeasure],'Date'[Week]=SELECTEDVALUE('Date'[Week])-1)
VAR _diff_rate = ABS(IF(SELECTEDVALUE('Date'[Week])=1,0, DIVIDE(_cur_week-_pre_week,_pre_week)))
VAR _result = IF(_cur_week>=_pre_week,_diff_rate,-_diff_rate)
RETURN
_result

vcgaomsft_1-1704788248301.png
Next, you can set the conditional format according to your needs.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @VDebande ,

Please try:

Diff =
IF (
    SELECTEDVALUE ( 'Date'[Week] ) = 1,
    0,
    [YourMeasure]
        - CALCULATE (
            [Total Profit],
            'Date'[Week]
                = SELECTEDVALUE ( 'Date'[Week] ) - 1
        )
)

vcgaomsft_0-1704787760454.png

Diff% = 
VAR _cur_week = [Total Profit]
VAR _pre_week = CALCULATE([YourMeasure],'Date'[Week]=SELECTEDVALUE('Date'[Week])-1)
VAR _diff_rate = ABS(IF(SELECTEDVALUE('Date'[Week])=1,0, DIVIDE(_cur_week-_pre_week,_pre_week)))
VAR _result = IF(_cur_week>=_pre_week,_diff_rate,-_diff_rate)
RETURN
_result

vcgaomsft_1-1704788248301.png
Next, you can set the conditional format according to your needs.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Ritaf1983
Super User
Super User

Hi @VDebande 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.