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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
rainchong7401
Helper III
Helper III

How to add Font color for Previous Year

Hi Friends,
I'm having a issue 
Which is how to add font color by using confitional formatting.
Since these columns are created by using measure instead of a legit column.
How should I add color for it? 
Especially for previous year font color. 

Kindly assist.

rainchong7401_0-1669170427021.png

rainchong7401_1-1669170717670.png

 

1 ACCEPTED SOLUTION
v-jialluo-msft
Community Support
Community Support

Hi @rainchong7401 ,

 

Please follow these steps:

(1) Create a new measure

 

COLOR =

VAR _YEAR = MAX('Table'[Date].[Year])

RETURN IF(_YEAR = Parameter[Parameter Value] , "GREEN" , IF(_YEAR = Parameter[Parameter Value] -1, "RED" ,"PINK"))

 

(2)Final output

vjialluomsft_0-1669257964575.png

 

vjialluomsft_1-1669257964578.png

 

If this is not what you need, please provide sample files or point it further

 

Best Regards,

Gallen Luo

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

4 REPLIES 4
v-jialluo-msft
Community Support
Community Support

Hi @rainchong7401 ,

 

Please follow these steps:

(1) Create a new measure

 

COLOR =

VAR _YEAR = MAX('Table'[Date].[Year])

RETURN IF(_YEAR = Parameter[Parameter Value] , "GREEN" , IF(_YEAR = Parameter[Parameter Value] -1, "RED" ,"PINK"))

 

(2)Final output

vjialluomsft_0-1669257964575.png

 

vjialluomsft_1-1669257964578.png

 

If this is not what you need, please provide sample files or point it further

 

Best Regards,

Gallen Luo

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Jialluo,
This is not what I want 

v-jialluo-msft
Community Support
Community Support

Hi @rainchong7401 ,

 

You can set conditional formatting directly here to change the font color of the measure

vjialluomsft_0-1669187226840.png

 

Font color can also be controlled by additional measures

 

COLOR =

VAR _YEAR = MAX('Table'[Date].[Year])

RETURN IF(_YEAR = 2021 , "YELLOW" , "PINK")

 

 

vjialluomsft_1-1669187226841.png

 

 

Best Regards,

Gallen Luo

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Gallen,
This is more like hard coded. What if today I select 2020 as current year. Previous year is 2019. 
Which mean 2019 return me as hard coded color ?

I want it to be chaging color dynamically based on my selection. (Current year = Green, Previous Year = Red)
If I select 2018 as current year return green font. previous year 2017 return Red
If I select 2020 as current year return green font. previous year 2019 return Red

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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