Color-code Visualizations using Grouping in Power BI

Data source used for this post is the ‘Internet Sales’ data mart of the ‘AdventureWorksDW2017´ SQL server database.

Grouping clearly helps to better visualize and analyze our data. In this example, we will look at grouping the field values and use them to format the color of the visualizations.

Let’s look at the steps involved in doing this.

1) Create a group on ‘Product Category’. Right-click on the ‘Product Category’ field on the ‘Fields’ pane and click on ‘New Group’. New window will be opened as in the screenshot below.

2) Create two groups under the ‘Product Category (groups)’ as in the screenshot below and name them as ‘Red’ and ‘Green’. Red group consists ‘Accessories’, ‘Clothing’ & ‘Components’ and Green group consists ‘Bikes’.

3) Now, create a Stacked bar chart and drop ‘Product Category’ in Axis field and the ‘Sales Amount’ measure in the Value field of the chart.

4) Format the colors of the bars on the dashboard using the newly created groups.
a. First right-click on the ‘Default color’ and select the ‘Conditional formatting’ under the Format -> Data colors section to open the ‘Default color – Data colors’ window.
b. Next, choose ‘Format by’ as ‘Field value’ and then from the drop-down under the ‘Based on field’, select the newly created ‘Product Category (groups)’ field. ‘Summarization’ can be ‘First’ or ‘Last’ as one field value of the Product Category has been grouped under one group.

5) After the above step, Stacked bar chart is formatted as below – ‘Bikes’ product Category is shown in green and the rest in ‘Red’ as grouped.

Hope this post helps you!

Leave a comment