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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
curious_Member
Regular Visitor

Conditional formatting measure which apply font color based on selected measure

Hi everyone,

 

I am trying to apply the same font color conditional format for many columns using a measure instead of configure it using a rule manually to each column.

The idea is that if I want to change the rule in the future I can do it changing the DAX formula of the conditional format measure instead of change it in each column one by one.

 

Here is the example:

I have 1 table in my datasource:

TABLE 1: date, product, sales, forecast, quota

I created 4 measures:

MEASURE salesOverQuota = DIVIDE(SUM(sales)-SUM(quota), SUM(quota), 0)

MEASURE forecasOverQuota = DIVIDE(SUM(forecast)-SUM(quota), SUM(quota), 0)

MEASURE salesOverForecast = DIVIDE(SUM(sales)-SUM(forecast), SUM(forecast), 0)

MEASURE salesYoYGrowth(%) =

    DIVIDE(

        SUM(sales)

        - CALCULATE(

                SUM(sales)

                ,SAMEPERIODLASTYEAR('Reference Date'[Date])
          ),
        , 

        CALCULATE(

                SUM(sales)

                ,SAMEPERIODLASTYEAR('Reference Date'[Date])
          )
        , 0
        )

 

In the report I included a matrix using product as rows and the measures as values.

To apply the same font color conditional format I created a new measure:

MEASURE overFontColor = IF(SELECTEDMEASURE() > 0, "#0D8224", "#FF0D00") --(green if true, red if false)

 

I select "overFontColor" as field value which should be based on the font color but it does not work (all values are red or green and the rule is not applied by cell values).

Any idea to solve the problem?

Thanks in advance.

 

 

 

 

1 REPLY 1
amitchandak
Super User
Super User

@curious_Member , I checked this selectedmeasure couple of days back and this did work atleast with calculation group and it did not work

 

Using code given in my blog- I was able to get selected measure in case of field parameters, and check if that can help

 

check for selectedmeasure code

https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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