cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BI_Analyticz
Helper V
Helper V

Conditional Format Based on Previous Quater Value

I am trying to conditional format based on previous Qtr value. If the cell value is greater than previous qtr value then color the current cell as "RED". Data sample is below.

 

NameDateYearQtrHours
John01-Jan-202020120
John01-May-202020230
John01-Aug-202020310
John01-Dec-202020440
Rick01-Jan-202020110
Rick01-May-202020220
Rick01-Aug-202020310
Rick01-Dec-202020410
John01-Jan-212021140
John01-May-212021210
John01-Aug-212021320
John01-Dec-212021410
Rick01-Jan-212021160
Rick01-May-212021230
Rick01-Aug-212021310
Rick01-Dec-212021410

 

I used a measure as below to condtional format and the output is correct but it is always coloring the first column as RED since there is no data before that period. I am using a Calendar Table (DateDim) too.

 

ConFormat1 = SWITCH(TRUE(),SUM(Sheet1[Hours]) > CALCULATE (SUM ( Sheet1[Hours] ),
PREVIOUSQUARTER( DateDim[Date])), "RED")
 
If you look at below 2020 Q2 color is correct since previous qtr value is less. But 2020 Q1 shouldn't be RED. 
 
BI_Analyticz_0-1618896545557.png

Is there any better way to do this or am I missing something?

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @BI_Analyticz 

Please try the below measure for the font color conditional formatting -> format by Field value.

The table names are a bit different than yours, but I hope you can easily fix it to apply to your model.

 

Picture3.png

 

ConFormat Font Color =
SWITCH (
TRUE (),
SUM ( Data[Hours] )
> CALCULATE ( SUM ( Data[Hours] ), PREVIOUSQUARTER ( 'Calendar'[Date] ) )
&& NOT ISBLANK (
CALCULATE ( SUM ( Data[Hours] ), PREVIOUSQUARTER ( 'Calendar'[Date] ) )
), "Red"
)

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: https://www.linkedin.com/in/jihwankim1975/


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

2 REPLIES 2
BI_Analyticz
Helper V
Helper V

Worked perfectly.. Thanks a lot..

Jihwan_Kim
Super User
Super User

Hi, @BI_Analyticz 

Please try the below measure for the font color conditional formatting -> format by Field value.

The table names are a bit different than yours, but I hope you can easily fix it to apply to your model.

 

Picture3.png

 

ConFormat Font Color =
SWITCH (
TRUE (),
SUM ( Data[Hours] )
> CALCULATE ( SUM ( Data[Hours] ), PREVIOUSQUARTER ( 'Calendar'[Date] ) )
&& NOT ISBLANK (
CALCULATE ( SUM ( Data[Hours] ), PREVIOUSQUARTER ( 'Calendar'[Date] ) )
), "Red"
)

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: https://www.linkedin.com/in/jihwankim1975/


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors