Forum Discussion
Legend with dynamic data in Shape MAP
- 11 months ago
kushanNa
Okay, it seems that i'd created my own problem.
The original thing, as described in this topic and with above measures, does do the trick.For some reason, the issue had experienced was due to the fact that I'd checked Show items with no data for the origin. (I had that checked from an earlier version where I'd tried to give a color to the "empty" shapes)
I do not understand why, but unchecking this setting does the trick and shows me what i need!
Thanks for your help!
Hi tjalleph ,
you’re filtering on the wrong thing in Legend.
MAX('Legend'[Type]) returns the lexical maximum of the text values (e.g. ">1.5h"), not the category you are currently evaluating for each origin. That means most origins are filtered away and you end up with blanks on the Shape Map.
Do not filter by MAX('Legend'[Type]). Instead map each origin to its category, and then map that category to the legend index (a numeric value) that drives the color.
Add a small lookup that converts the category text (_traveltime_category) into the numeric Index from your Legend table, and use that as the color saturation measure.
Sample fix (keep your existing measures for travel time and category, then add a color index measure):
Your existing measures (unchanged) _traveltime = MIN('TimeTravel (arrays)'[travel_time (min) ]) _traveltime_category = if([_traveltime] <= 15, "<15 min", if([_traveltime] > 15 && [_traveltime] <= 30, "<30 min", if([_traveltime] > 30 && [_traveltime] <= 60, "< 1h", if([_traveltime] > 60 && [_traveltime] <= 90, "1-1.5h", ">1.5h"))))
New color index measure (maps category to the legend index) _CategoryIndex = COALESCE( LOOKUPVALUE('Legend'[Index], 'Legend'[Type], [_traveltime_category]), 0 )
Use
Legend: Type (from the Legend table)
Color saturation: CategoryIndex
Please mark this post as solution if it helps you. Appreciate Kudos.
Thanks!Okay, it's getting closer, i think.
The _CategoryIndex seems to work, see righthanded figure. However, the moment I add Type as a legend, I end up with the lefthanded figure.
Any additional ideas, FarhanJeelani ?