Forum Discussion
Default value on card if data on one table
For simplified purposes, I have a table like this:
| Region | Value |
| AMERICAS | 90% |
| ASIA | 85% |
| EUROPE | 95% |
| Overall | 97% |
Is it possible to write a measure (for a card visual) that would show "Overall" value by default when nothing is selected and then would switch to either the AMERICAS, ASIA, or EUROPE value using a slicer?
Thanks.
Please try the measure below:
Card Value = VAR SelRegion = SELECTEDVALUE(RegionTable[Region]) RETURN CALCULATE( MAX(RegionTable[Value]), RegionTable[Region] = COALESCE(SelRegion, "Overall") )
4 Replies
- cengizhanarslan
Super User
Please try the measure below:
Card Value = VAR SelRegion = SELECTEDVALUE(RegionTable[Region]) RETURN CALCULATE( MAX(RegionTable[Value]), RegionTable[Region] = COALESCE(SelRegion, "Overall") )- JinDRFrequent Visitor
Worked great, was just what I needed. Thank you!!
- BA_Pete
Super User
Hi JinDR ,
cengizhanarslan has provided a good working solution, but I would suggest that the 'correct' way to handle this would be to remove the 'Overall' value from your data and have it be calculated on the fly from your unfiltered table (assuming that the 'Overall' value is just a percentage of the values over all Regions).
Best practice would dictate that percentages should not really be calculated as static values before reaching the model so they remain dynamic and can be recalculated by the model when user/context filters change (or are removed, as in this case).
Pete
- Kedar_Pande
Super User
Measure:
Default Card =
IF(
ISFILTERED(Region),
SELECTEDVALUE(Region[Value]),
CALCULATE(AVERAGE(Region[Value]), Region = "Overall")
)Card shows 97% default. Slicer filters to region value.
If this answer helped, please click 👍 or Accept as Solution.
-Kedar
LinkedIn: https://www.linkedin.com/in/kedar-pande