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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
samcasce
New Member

Conditional Formatting basede on previous values the Matrix columns

Hi, can someone tell me if we can format the values of the Matrix as required:

Screen Shot 08-01-19 at 04.02 PM.PNG

The Icon un each row depends of value on the previous column on that same row.

1 ACCEPTED SOLUTION
SteveCampbell
Memorable Member
Memorable Member

You can create this measure:

 

Icon =
VAR _val =
 CALCULATE ( SUM (  Sales[Sales] ) )
-
 CALCULATE (  SUM ( Sales[Sales] ),
        PREVIOUSMONTH ( 'DateTime'[Date] )    )
        
RETURN
    SWITCH ( TRUE (),
 
_val < 0-1
_val = 00,
 _val > 
01 )

 Change the RED to match your columns!

 

Then, on your matrix, go to the format properties.
Under conditional formatting, select the column and turn on icons, then click advanced editor:

 

mm.png

In advanced controls, select the following options:

nnn.png

 

 

Want even more help with icons?! Check this awesome blog!

https://powerbi.tips/2019/07/icons-upon-icons/

 

Happy icon-ing Cat LOL Woman Tongue Robot LOL



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @SteveCampbell 

 

How does this work for colums with weeknumbers? There is no "previousweek" formula in PBI 😞 

I use this formula:

Icon =
VAR _val =
CALCULATE ( SUM ( Datagrunnlag[Antall solgt]) )
-
CALCULATE ( SUM ( Datagrunnlag[Antall solgt] ),
Dates[Weeknumber]-1)
 
RETURN
SWITCH ( TRUE (),
_val < 0, -1,
_val = 0, 0,
_val > 0, 1 )


See screenshot

Henristu_0-1605188810048.png

 

Use a date table with an index (Example here) 

 

The week index is rolling, with current week being 0, last week -1 and so on. So whatever week you need, you can get the week index and subtract 1 to always get the previous. This way, it doesn't matter if you week falls in a different year.

 

You need to assign this to a variable and filter the dates table on it:

 

Icon =
VAR _lastweek = SELECTEDVALUE('Dates'[week index]) - 1
VAR _val =
CALCULATE ( SUM ( Datagrunnlag[Antall solgt]) )
-
CALCULATE ( SUM ( Datagrunnlag[Antall solgt] ),
Dates[week index] = _lastweek )
 
RETURN
SWITCH ( TRUE (),
_val < 0, -1,
_val = 0, 0,
_val > 0, 1 )

 

 



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



SteveCampbell
Memorable Member
Memorable Member

You can create this measure:

 

Icon =
VAR _val =
 CALCULATE ( SUM (  Sales[Sales] ) )
-
 CALCULATE (  SUM ( Sales[Sales] ),
        PREVIOUSMONTH ( 'DateTime'[Date] )    )
        
RETURN
    SWITCH ( TRUE (),
 
_val < 0-1
_val = 00,
 _val > 
01 )

 Change the RED to match your columns!

 

Then, on your matrix, go to the format properties.
Under conditional formatting, select the column and turn on icons, then click advanced editor:

 

mm.png

In advanced controls, select the following options:

nnn.png

 

 

Want even more help with icons?! Check this awesome blog!

https://powerbi.tips/2019/07/icons-upon-icons/

 

Happy icon-ing Cat LOL Woman Tongue Robot LOL



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



Hi - when I follow this solution all my formatting is returning an increase from the previous month - even when there's a decrease in value. I added the measure to a matrix and all the values are 1. 

My date field is in Date format and I've also tried when set to DateTime.
Can you help please?

Many thanks

Is there a way to do this comparison against the previous week instead of the previous month?

I noticed there is no PREVIOUSWEEK() function...

 

Thanks!

Hi Steve, This solution is perfect!!

Thank's

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors