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
Anonymous
Not applicable

Conditional Formatting based on previous Value

Hi,

 

I have the above table as a Matrix in Power BI:

 

MONTHTICKETS UPDATED #STOCK REPLENISHED #INCREASED MPL / MDQ #
May 201994810
June 201911479
July 20198528

 

I would like to format as below:

cond format.JPG

I need to create a measure for each column, that will allow me to format as such:

 

IF( FOLLOWING MONTH Value > PREVIOUS MONTH Value , Green Color ,
IF( FOLLOWING MONTH Value < PREVIOUS MONTH Value , Red Color )) 

 

Help would be really appreciated.

 

Regards,

Robin

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

I did an example for 1 column.
Create 2 new columns:

Previous Month Tickets =
VAR prev_month =
    PREVIOUSMONTH ( T13[MONTH] )
RETURN
    IF (
        CALCULATE (
            SUM ( T13[TICKETS UPDATED #] ),
            FILTER (
                T13,
                prev_month = T13[MONTH]
            )
        )
            = BLANK (),
        0,
        CALCULATE (
            SUM ( T13[TICKETS UPDATED #] ),
            FILTER (
                T13,
                prev_month = T13[MONTH]
            )
        )
    )
Colors =
IF (
    T13[TICKETS UPDATED #] > T13[Previous Month Tickets],
    "GREEN",
    "RED"
)

Then format according to field value

2019-07-08 13_44_13-papercut - Remote Desktop Connection.png

 

Cheers!
A

View solution in original post

7 REPLIES 7
jdbuchanan71
Super User
Super User

Hello @Anonymous 

You can do this with measures that compare the prior month amount to the current month amount the return a color string based on the compare.  I chose slightly lighter colors that the standard red and green.

Format Tickets Update = 
VAR PriorMonthAmt = CALCULATE( [TICKETS UPDATE #] , PARALLELPERIOD(Dates[Date],-1,MONTH ) )
VAR Compare = IF ( ISBLANK( PriorMonthAmt ), BLANK(), [TICKETS UPDATE #] - PriorMonthAmt)
RETURN 

SWITCH (
    TRUE(),
    Compare = 0, "none",
    Compare < 0, "#ff7f7f",
    Compare > 0, "#7fbf7f")
Format Stock Replenished = 
VAR PriorMonthAmt = CALCULATE( [STOCK REPLENISHED #] , PARALLELPERIOD ( Dates[Date],-1,MONTH ) )
VAR Compare = IF ( ISBLANK ( PriorMonthAmt ), BLANK(), [STOCK REPLENISHED #] - PriorMonthAmt)
RETURN 

SWITCH (
    TRUE(),
    Compare = 0, "none",
    Compare < 0, "#ff7f7f",
    Compare > 0, "#7fbf7f")
Format MPL / MDQ = 
VAR PriorMonthAmt = CALCULATE( [INCREASED MPL / MDQ #] , PARALLELPERIOD(Dates[Date],-1,MONTH ) )
VAR Compare = IF ( ISBLANK( PriorMonthAmt ), BLANK(), [INCREASED MPL / MDQ #] - PriorMonthAmt)
RETURN 

SWITCH (
    TRUE(),
    Compare = 0, "none",
    Compare < 0, "#ff7f7f",
    Compare > 0, "#7fbf7f")

Then you use the conditional formatting over the field 

conditionalformat.jpg

conditionalformattable.jpg

Anonymous
Not applicable

 

I'm struggling with the MONTH column formatting.

How do you get the MONTH column in acceptable date format for PARALLELPERIOD or PREVIOUSMONTH functions to work?

Anonymous
Not applicable

All good, I found the function that transforms text to date: DATEVALUE()

ALl sorted thanks guys 🙂

Anonymous
Not applicable

Hi @Anonymous 

I did an example for 1 column.
Create 2 new columns:

Previous Month Tickets =
VAR prev_month =
    PREVIOUSMONTH ( T13[MONTH] )
RETURN
    IF (
        CALCULATE (
            SUM ( T13[TICKETS UPDATED #] ),
            FILTER (
                T13,
                prev_month = T13[MONTH]
            )
        )
            = BLANK (),
        0,
        CALCULATE (
            SUM ( T13[TICKETS UPDATED #] ),
            FILTER (
                T13,
                prev_month = T13[MONTH]
            )
        )
    )
Colors =
IF (
    T13[TICKETS UPDATED #] > T13[Previous Month Tickets],
    "GREEN",
    "RED"
)

Then format according to field value

2019-07-08 13_44_13-papercut - Remote Desktop Connection.png

 

Cheers!
A

Anonymous
Not applicable

Hello, I tired thre abovce, but when I go to conditional formatting aand then select format by field the box for based on field is red and it wont let me choose the field I creatd above.

Anonymous
Not applicable

Thanks mate, that's exactly what I'm looking for!

Anonymous
Not applicable

You can optimise the above to be in one column (one go),
I did it in 2 steps for better understanding the steps.

Good Luck!

Helpful resources

Announcements
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.

Top Kudoed Authors