Forum Discussion

lgoggs's avatar
lgoggs
New Member
2 years ago
Solved

Changing colour for multiple series based on filter selection in clustered bar chart

Hi, I've been playing around with this and wondered if it can be done.    I have a category column called 'activity', which is the y-axis on a clustered bar chart. I then have 3 series called 'curr...
  • MFelix's avatar
    MFelix
    2 years ago

    Hi lgoggs ,

     

    For this you need to create a table with the Activity and Metric:

     

    Now add the folllowing measures:

    Values = SWITCH(
    			SELECTEDVALUE('Activity / Metric'[Metric]),
    			"current_year", CALCULATE(
    				SUM(activity[current_year]),
    				activity[activity] = SELECTEDVALUE('Activity / Metric'[Activity])
    			),
    			"na", CALCULATE(
    				SUM(activity[na]),
    				activity[activity] = SELECTEDVALUE('Activity / Metric'[Activity])
    			),
    			"region_ha", CALCULATE(
    				SUM(activity[region_ha]),
    				activity[activity] = SELECTEDVALUE('Activity / Metric'[Activity])
    			)
    		)
    
    
    
    
    Colors = SWITCH(
    
    			SELECTEDVALUE(activity[region]),
    			"Liverpool", SWITCH(
    
    				SELECTEDVALUE('Activity / Metric'[Metric]),
    				"current_year", "blue",
    				"na", "Green",
    				"region_ha", "Yellow"
    			),
    			"Sheffield", SWITCH(
    
    				SELECTEDVALUE('Activity / Metric'[Metric]),
    				"current_year", "pink",
    				"na", "orange",
    				"region_ha", "Grey"
    			)
    		)

    Now create your visualization in the following way:

    • Y-Axis:
      • Actvity/Metric[Activity]
      • Actvity/Metric[Metric]
    • X-Axis
      • Values (Measure)
    • Condittional formatting
      • Colors (Measure)

     

     

    You can change the colors by HEX codes if you want to.

     

    PBIX file attach.