This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
I'm getting weird results with a DAX calculation I'm using for conditional formatting of the new card type and having trouble finding a relevant answer.
My data is in two tables:
Metric (a dimension table)
| MetricID | MetricName |
| 1 | All Issues |
| 2 | High Severity Issues |
MetricFact (my fact table)
| MetricID | MeasureDate | MeasureValue |
| 1 | 1/1/26 | 10 |
| 1 | 2/1/26 | 20 |
| 1 | 3/1/26 | 30 |
| 2 | 1/1/26 | 2 |
| 2 | 2/1/26 | 4 |
| 2 | 3/1/26 | 2 |
The two are connected by the MetricID field and on the Metric table I've added a piece of DAX that dynamically determines the color:
The problem is, this works great with a matrix visual, but if I try to use it to conditionally format the cards, it always turns them yellow implying a single value for SELECTEDVALUE() is not available. How do I get the category for each card successfully to determine the color if SELECTEDVALUE() doesn't return it?
Solved! Go to Solution.
Hello @schwartzaw ,
The reason your card visual is defaulting to yellow is likely due to filter context.In a Matrix visual, each row or column provides a specific context , hence SELECTEDVALUE can easily identify which metric is being looked at. But, a Card visual summarizes your entire dataset into a single value. Unless you have a Slicer or a Filter on the page selecting exactly one Metric Name, SELECTEDVALUE returns a blank, which triggers your default.
Here is how you can handle : update your dax
I have shared an example above , you can update as per need.
Specific to your case :
Please note, when you put multiple metrics into a single New Card visual, the visual calculates your DAX measure once for the entire card, not separately for each individual value or data bar inside it. so better to use 2 separate measures to use it under series values for conditional formatting.
I hope this helps.
Cheers.
Did I answer your query ? Mark this as solution to make it available for others.
Yea I am curious about this too, is this intended behaviour?
Hello @schwartzaw ,
The reason your card visual is defaulting to yellow is likely due to filter context.In a Matrix visual, each row or column provides a specific context , hence SELECTEDVALUE can easily identify which metric is being looked at. But, a Card visual summarizes your entire dataset into a single value. Unless you have a Slicer or a Filter on the page selecting exactly one Metric Name, SELECTEDVALUE returns a blank, which triggers your default.
Here is how you can handle : update your dax
I have shared an example above , you can update as per need.
Specific to your case :
Please note, when you put multiple metrics into a single New Card visual, the visual calculates your DAX measure once for the entire card, not separately for each individual value or data bar inside it. so better to use 2 separate measures to use it under series values for conditional formatting.
I hope this helps.
Cheers.
Did I answer your query ? Mark this as solution to make it available for others.
Card visuals have no row context - SELECTEDVALUE needs filter context from MetricID/MetricName.
WhatColor =
VAR MetricName = VALUES(Metric[MetricName])
RETURN
SWITCH(
TRUE(),
COUNTROWS(MetricName) = 1 && "All Issues" IN MetricName, "blue",
COUNTROWS(MetricName) = 1 && "High Severity Issues" IN MetricName, "red",
"yellow"
)
Matrix works because row context creates filter context per MetricID. Cards need explicit filter (slicer on MetricName) or this VALUES approach.
Better - add MetricName slicer above cards. SELECTEDVALUE works perfectly with slicer filter context.
@Kedar_Pande , while continuing to try to understand what's going on with the card, I created a new page to use as a tooltip and assigned it to the Card as the tooltip. This worked exactly as expected, filtering the tooltip by the name of the Metric I was hovering over. It seems like the card has the ability to share the appropriate context with a tooltip. I'm not sure what exactly this tells me about the card visual and what I should be expecting in DAX, but figured I'd add that info in.
Thank you. I think this offers the clearest explanation of why what I'm trying doesn't work - the new card does not create a row context when I add something to the categories field. That said, I tried the code you provided and it didn't produce the desired result unfortunately.
The behavior is the same root cause as SELECTEDVALUE failing when multiple rows exist in context. You could use MAX instead of SELECTEDVALUE() for it to return your CF but it might not be correct value. For a better solution you need to return a single MetricName in your card visual.
I'm not quite sure I follow. I'm assuming you are saying placing the MetricName in the Categories field for a card isn't the same as placing MetricName in the Rows field (ie it doesn't reduce the context), but I guess I'm finding that counter intuitive considering you end up with something approximately visually equivalent in my toy example. But more importantly, does that mean there's no way for the DAX to leverage the Categories field for conditional formatting? It seems like a logical use case might be to show a series of cards of sales per country and color each card differently. It seems not workable to have to create one card per country since you wouldn't necessarily know up front which countries might be in the data. And it seems like that's what the new card is trying to solve for.
Hi @schwartzaw
SELECTEDVALUE returns a value only when there is only one value.
IN a matrix, it works if you group the Metric[MetricName], in a card you cannot. So you should filter one value for that column. If you show me what you are doing in detail, I can be more precise
Best
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
Here's an image of what I'm trying to accomplish. You can see with the matrix that the DAX works as expected, coloring each row appropriately but does not work for the new card (which it colors both yellow). It may be a misunderstanding on my part, but I'm unclear why SELECTEDVALUE() works in the matrix as I'd expect but not in a card.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |