Forum Discussion
Vickar
Advocate II
3 years agoPower BI : Dynamic Colors for TopN values on Clutered Column Chart
Requirement: Assign dynamic colors to the subcategory values on the clustered column chart. Background: The chart shows Top 6 subcategories by SalesAmount and rest other categories as Others. There ...
- 3 years ago
shout-out to Amira Bedhiafi for providing the solution on stackoverflow
Below is the DAX solution to the problem in the [SelectedSubcategoryColor] measureSelectedSubcategoryColor = VAR _CurrentSubcategory = SELECTEDVALUE ( Subcategory[SubcategoryName] ) VAR _AllSubcategories = ALLSELECTED( Subcategory ) VAR _CurrentRank = RANKX( _AllSubcategories, [Sales], , DESC ) RETURN SWITCH( TRUE(), _CurrentRank = 1, "Red", _CurrentRank = 2, "Green", _CurrentRank = 3, "Blue", _CurrentRank = 4, "Orange", _CurrentRank = 5, "Purple", _CurrentRank = 6, "Yellow", _CurrentSubcategory = "Others", "Grey", "Black" )
VijayP
Community Champion
3 years agoLook at the change in TOPN formula , i have changed the number 6 with a slicer value
Vickar
Advocate II
3 years agoVijayP appreciate your feedback. The problem persists though. If I select less than 5 subcategories from the filter pane, the visual still breaks. Also, as part of the requirement, the visual should show max 7 data elements, 6 topn and rest as others. So the topn shouldn't come from the slicer, it should be static value as 6