Forum Discussion
Dynamic Top N Parameter doesn't work when adding a LEGEND to a Stacked Bar Chart
Anonymous , Try updating measure as
Rank_City =
RANKX(
ALLSELECTED('Dim_City'[City], 'Dim_SubCategory'[SubCategory]),
[Sales Amount],
,
DESC,
DENSE
)
And
TopNCity =
IF(
[Rank_City] <= 'TopN'[TopN Value],
1,
0
)
Ensure that the TopNCity measure is applied as a visual-level filter on your chart, and set it to show only values where TopNCity equals 1.
- Anonymous2 years agoNot applicable
Hi bhanu_gautam,
It didn't work as it says that columns used in ALLSELECTED must be from the same table:But thank you for the idea because from there, I tried to create a table that summarizes the City and Sub-Category, established a many-to-many relationship with the fact table. I used these columns in the chart and updated the rank measure as well:
Rank_City =RANKX(ALLSELECTED('Dim_City_Sub'[City],Dim_City_Sub[Sub-Category]),[Sales Amount],,DESC,DENSE)
This seems to fix the issue, but the legend doesn't seem correct as all bars look unnatural + they have similar width..