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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
minhthemeanie
New Member

Dynamic Color Formatting with Field Parameters

I am currently running into some issues with gradient color formatting when using Field parameters for on-visual dimensions' modification. I created a Measure like this:

 

Selected Metric = 
VAR SelectedMetricName = SELECTEDVALUE('Column Chart Metrics'[Column Chart Metrics Fields])
RETURN
SWITCH(
    SelectedMetricName,
    "Total Cases", [Total Cases],
    "Total Deaths", [Total Deaths],
    "% Infected", [Avg % infected],
    BLANK()  -- Fallback in case no metric is selected
)

 

which I apply to column gradient color formatting for this visual

minhthemeanie_0-1717913041256.png

minhthemeanie_1-1717913071548.png

However, since it kept returning errors, I'm desperately seeking some advice on this. Is there any problem with my DAX or the way I apply it? 😥

 

 

4 REPLIES 4
rajendraongole1
Super User
Super User

Hi @minhthemeanie -Your approach with the DAX measure to handle dynamic metrics is correct, but there might be some issues with how you're applying it in the gradient color formatting.

can you check the measure Selected Metric correctly returns values based on the selected metric. You can test it by placing it in a table or card visual to verify the output.

In the Conditional Formatting set the "Based on field" to your Selected Metric measure.configure your color gradient settings.

Now try dynamically apply gradient color formatting based on the selected metric in your column chart visual.

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





I dont really understand your approach for testing this out but here goes the table for my data, the conditional formatting does not really correspond with the column chart, since each of the columns represents one value from the metric?

minhthemeanie_1-1717944376625.png

 

Anonymous
Not applicable

Hi @minhthemeanie ,

Try using bookmarks to toggle the visibility of the three visuals, as well as conditional formatting:

vcgaomsft_0-1717997895809.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

I have thought of it in the first place. Yet, it would make the visual processing slower to a certain extent while I am actually trying to optimize it. Thanks for your suggestion anyway!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.