Forum Discussion
dynamic grouping for 'legend' in a viz (map) driven by parameter
- 1 year ago
That should still be possible but you need to specify in the measure that the profit grouping is to be summarized by product and location.
Sales by Grouping = VAR __TBL = ADDCOLUMNS ( SUMMARIZE ( Sales, Sales[Fruit],Sales[State] ), "@Amt", CALCULATE ( SUM ( Sales[Sales] ) ), "@Grouping", IF ( CALCULATE ( SUM ( Sales[Sales] ) ) >= [Parameter Value], "Yes", "No" ) ) VAR __FILTERED_TBL = FILTER ( __TBL, [@Grouping] IN VALUES ( 'Grouping'[Grouping] ) ) RETURN SUMX ( __FILTERED_TBL, [@Amt] )
hI jakubk
Create a disconnected table containing the label.
Write a measure to that distributes the sales/profit into into Yes or No depending the budget parameter value.
Grouping Amount =
VAR _GROUPING =
VALUES ( 'Grouping'[Grouping] ) -- yes or no
VAR _TBL =
ADDCOLUMNS (
SUMMARIZE ( Sales, Sales[Fruit] ),
"@Amt", CALCULATE ( SUM ( Sales[Sales] ) ),
"@Grouping", IF ( CALCULATE ( SUM ( Sales[Sales] ) ) >= [Parameter Value], "Yes", "No" )
)
RETURN
SUMX (
//filter the virtual table on [@Grouping] and sum the [@Amt] grouped by Sales[Fruit]
FILTER (
_TBL,
[Grouping] IN _GROUPING
),
[@Amt]
)
Please see attached sample pbix.
Hi,
I already have a measure doing that - I tried yours but I can't use it in the map as a legend either
What i'm trying to do is add a dynamic legend to the map - in this example i've hardcoded "hardcoded" as >=20. But i'd like the 'budget' slider to modify which products fall into the 'yes/no' categories on the map
I don't have an 'upload attachment' option to share my example pbix
- danextian1 year ago
Super User
That should still be possible but you need to specify in the measure that the profit grouping is to be summarized by product and location.
Sales by Grouping = VAR __TBL = ADDCOLUMNS ( SUMMARIZE ( Sales, Sales[Fruit],Sales[State] ), "@Amt", CALCULATE ( SUM ( Sales[Sales] ) ), "@Grouping", IF ( CALCULATE ( SUM ( Sales[Sales] ) ) >= [Parameter Value], "Yes", "No" ) ) VAR __FILTERED_TBL = FILTER ( __TBL, [@Grouping] IN VALUES ( 'Grouping'[Grouping] ) ) RETURN SUMX ( __FILTERED_TBL, [@Amt] )- jakubk1 year ago
Helper I
Thanks! - works great