- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Overwriting Color conditional formatting
I would like to apply Color conditional formatting to a visual dynamically between 40 different measures.
How can I do this with a calculation group and specifically using DAX expressions that only apply to these like Selectedmeasure and Isselectedmeasure?
I have tried to create a measure that returns a random colour as hex and input this into my visual, but how do I overwrite this specific measure with a calculation group(s) while using the previously mentioned dax expressions?
I have to call out the measure that I want to overwrite while at the same time allowing all my measures to overwrite it.
How can I go about this please?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Silvard,
You're correct. You cannot directly place a calculation item into the fx field for conditional formatting, as it only accepts measures, not calculation items. This is a current platform limitation.
To work around this, use SELECTEDMEASURE() in a helper measure that can be referenced in the fx field. Create a helper measure that references SELECTEDMEASURE(), reflecting the measure selected via your calculation group. Then, use that measure in your fx conditional formatting logic.
Additionally, you can create a calculation group for your measures. Use Tabular Editor to define a calculation group (e.g., "Metric Selector") and add 40 calculation items, one per measure.
Dax Measure for Metric Selector:
Name: Sales Amount
Expression: [Sales Amount]
Dax Measure For Color Formatting:
Color Formatting Measure =
VAR _current = SELECTEDMEASURE()
VAR _previous = CALCULATE(_current, SAMEPERIODLASTYEAR('Date'[Date]))
RETURN
IF(
_current > _previous,
"#00FF00", // Green
IF(
_current < _previous,
"#FF0000", // Red
"#808080" // Grey for no change
)
)
Please ensure that your data model includes a valid 'Date' table marked as such to enable the SAMEPERIODLASTYEAR function to operate correctly.
Apply Conditional Formatting in Visual: Once you have a measure that returns color values, select your visual. Navigate to the Format pane > Data colors (or Font color), and click the fx button. Choose Format by: Field value, then select the Color Formatting Measure.
This will dynamically apply color formatting based on the chosen measure, displaying green if the value is higher than last year, and red if it is lower.
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Silvard
Thank you for reaching out to the Microsoft fabric community forum. Thank you @ for your inputs on this issue.
After thoroughly reviewing the details you provided, I was able to reproduce the scenario, and it worked on my end. I have used it as sample data on my end and successfully implemented it.
Refer to the below solved issue for more information:
Solved: Conditional Formatting Calculation Groups - Microsoft Fabric Community
Navigate to the visualization pane, access the format visual section, and select the colours you prefer:
I am also including .pbix file for your better understanding, please have a look into it:
Also please check the links mentioned below:
SELECTEDMEASURE function (DAX) - DAX | Microsoft Learn
ISSELECTEDMEASURE function (DAX) - DAX | Microsoft Learn
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@thanks very much for your input.
Do you mind sharing your solution here as I'm unable to get the pbix over on my work laptop?
Please be aware that I'm still wanting to overwrite the conditional formatting measure in the fx colour of the visual but when the current value of the measure that is being used in the visual is positive compared to sameperiodlastyear, then Color green, when negative, colour red.
Appreciate your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Silvard,
Create a Calculation Group (e.g., Colo Formatting) in Tabular Editor. Add two calculation items: Table name should be “Data”.
Step 1: BaseMeasure :
SELECTEDMEASURE()
Step 2: ColorHex :
VAR CurrentValue = SELECTEDMEASURE()
VAR PreviousValue =
CALCULATE(
SELECTEDMEASURE(),
SAMEPERIODLASTYEAR('Date'[Date]) // Make sure 'Date' is your marked date table
)
RETURN
SWITCH(
TRUE(),
ISBLANK(CurrentValue) || ISBLANK(PreviousValue), "#808080", // Neutral for blanks
CurrentValue > PreviousValue, "#28a745", // Green
CurrentValue < PreviousValue, "#dc3545", // Red
"#808080" // Fallback
)
Select your visual (e.g., table, bar chart). Go to the Format pane > Data colors. Click the fx button. Choose: Format by: Field value. Based on field: ColorHex from your Colo Formatting calculation group. This will dynamically apply the correct colour to any selected measure, without hardcoding for each one.
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @v-kpoloju-msft
I may be wrong or doing something incorrectly, but I don't believe you can put a calculation item into fx of a visual and when trying , it's not letting me either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Silvard,
You're correct. You cannot directly place a calculation item into the fx field for conditional formatting, as it only accepts measures, not calculation items. This is a current platform limitation.
To work around this, use SELECTEDMEASURE() in a helper measure that can be referenced in the fx field. Create a helper measure that references SELECTEDMEASURE(), reflecting the measure selected via your calculation group. Then, use that measure in your fx conditional formatting logic.
Additionally, you can create a calculation group for your measures. Use Tabular Editor to define a calculation group (e.g., "Metric Selector") and add 40 calculation items, one per measure.
Dax Measure for Metric Selector:
Name: Sales Amount
Expression: [Sales Amount]
Dax Measure For Color Formatting:
Color Formatting Measure =
VAR _current = SELECTEDMEASURE()
VAR _previous = CALCULATE(_current, SAMEPERIODLASTYEAR('Date'[Date]))
RETURN
IF(
_current > _previous,
"#00FF00", // Green
IF(
_current < _previous,
"#FF0000", // Red
"#808080" // Grey for no change
)
)
Please ensure that your data model includes a valid 'Date' table marked as such to enable the SAMEPERIODLASTYEAR function to operate correctly.
Apply Conditional Formatting in Visual: Once you have a measure that returns color values, select your visual. Navigate to the Format pane > Data colors (or Font color), and click the fx button. Choose Format by: Field value, then select the Color Formatting Measure.
This will dynamically apply color formatting based on the chosen measure, displaying green if the value is higher than last year, and red if it is lower.
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Silvard,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
02-02-2023 06:46 AM | |||
02-09-2025 02:16 AM | |||
02-03-2025 04:19 AM | |||
11-27-2024 01:18 PM | |||
01-24-2025 11:43 AM |
User | Count |
---|---|
12 | |
11 | |
10 | |
9 | |
9 |
User | Count |
---|---|
29 | |
16 | |
14 | |
13 | |
13 |