Forum Discussion

minhthemeanie's avatar
minhthemeanie
New Member
2 years ago

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

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

  • 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!!

     

     

     

    • minhthemeanie's avatar
      minhthemeanie
      New Member

      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?