Forum Discussion
group lines when all selected
Hi buchta
You can use a field parameter in the legend field of the visual, combined with a measure to filter it appropriately for the visual, so that it's filtered to "ISO Code" if ISO Code is filtered, otherwise filtered to "nothing". Similar to the method described here.
I have attached a sample PBIX to show how this works.
Steps I followed to set this up:
1. Create a field parameter Legend Field Parameter containing the ISO Code column, then edit the DAX expression to add an item named "BLANK" which does not have a valid field reference.
Legend Field Parameter =
{
( "ISO Code", NAMEOF ( 'DIM Container'[ISO Code] ), 0 ),
( "BLANK", "BLANK", 1 )
}
2. Create a measure called Legend flag. This measure returns 1 if the current field parameter should be used, otherwise 0.
Legend Flag =
VAR CurrentField =
MAX ( 'Legend Field Parameter'[Legend Field Parameter] ) -- Assume single selection
VAR ResultBoolean =
IF (
ISFILTERED ( 'DIM Container'[ISO Code] ),
CurrentField = "ISO Code",
CurrentField = "BLANK"
)
VAR Result =
INT ( ResultBoolean ) -- Convert to 0/1
RETURN
Result
3. Create a visual containing 'Legend Field Parameter'[Legend Field Parameter] as the Legend field, and apply a Top N visual-level filter on Legend Field Parameter, set to "Top 1 by Legend Flag":
3. Now when the ISO column is filtered, the ISO code is used as the Legend field, otherwise there is no legend:
You can adjust the logic within the Legend Flag as needed to apply different conditions.
Does something like this work for you?
Regards