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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
OmarSek
Regular Visitor

Conditional formatting using a value who change every year

I am working in project to calculate a score of each company of a same group. 

 

To calculate the score , each company has to provide x kpi each month ( x is a number of kpi that the company have to provide each year , so x change by year) , so companies provide y kpi ( y the number of kpi that each company provides each month which is equal or less to x) . 

 

I am using stacked colum chart to show the score by company and i am using a slicer of date ( by month) , i want to use data color function to show it the company provides all the kpi or not . 

 

Exemple : if the company provides all the kpi , the color is blue , else the color is grey. But the number of kpi to provide change each year. ( in 2021 , the number was 10, in 2022, the number is 12). 

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

According to your description, I create a sample.

vkalyjmsft_0-1647581736547.png

Here's my solution.

1. Create a KPI table, don't make relationship between the two tables.

vkalyjmsft_1-1647581868876.png

2. Create a measure.

Color =
IF (
    MAX ( 'Table'[Score] )
        >= MAXX (
            FILTER (
                ALL ( 'KPI BY YEAR' ),
                'KPI BY YEAR'[Year] = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
            ),
            'KPI BY YEAR'[KPI]
        ),
    "Blue",
    "Grey"
)

3. Select the stacked colum chart, in the Format pane, select Columns>Colors>fx, select the color measure in the dialog.

vkalyjmsft_2-1647582052447.png

vkalyjmsft_3-1647582141421.png

Get the correct result.

vkalyjmsft_4-1647582367730.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

View solution in original post

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

According to your description, I create a sample.

vkalyjmsft_0-1647581736547.png

Here's my solution.

1. Create a KPI table, don't make relationship between the two tables.

vkalyjmsft_1-1647581868876.png

2. Create a measure.

Color =
IF (
    MAX ( 'Table'[Score] )
        >= MAXX (
            FILTER (
                ALL ( 'KPI BY YEAR' ),
                'KPI BY YEAR'[Year] = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
            ),
            'KPI BY YEAR'[KPI]
        ),
    "Blue",
    "Grey"
)

3. Select the stacked colum chart, in the Format pane, select Columns>Colors>fx, select the color measure in the dialog.

vkalyjmsft_2-1647582052447.png

vkalyjmsft_3-1647582141421.png

Get the correct result.

vkalyjmsft_4-1647582367730.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

Greg_Deckler
Community Champion
Community Champion

@OmarSek So, seems like you would use an Enter Data query to create a table with the number of KPI's by year. Then you could create a measure that compared the number of entries (COUNTROWS perhaps) in a given year, compare that to the KPI table value and return 1 or 0 so that you could then use that measure in your conditional formatting.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I like the idea, i will try to implement it and i will let you know the result.

I create a table called KPI BY YEAR , with two columns YEAR and Num KPI , this table has a relationship with just Date table . 

I have a slicer of month, i am trying just to find the NUM KPI using dax formula but it doesn't function. 

This is my dax forumula : 

NumPKIYEAR = VALUES ('KPI BY YEAR'[Num KPI]) 

but i get an error.

amitchandak
Super User
Super User

@OmarSek , if you use legend or two measure you can not use conditional formatting. So stacked you might be using legend, so I doubt that.

 

Usually, color measure does a good job in that case

 

How to do conditional formatting by measure and apply it on pie? : https://youtu.be/RqBb5eBf_I4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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 Solution Authors
Top Kudoed Authors