Power BI Grouping is the process of combining or merging two or more values for further analysis. For example, When we are seeing products by category report, we may find very few records (unnoticeable products). Sometimes, it may be annoying to see all those underperforming products. In this situation, you can create a Power BI group by combining those records, and display it as one product.
In this article, we show you how to create groups in Power BI reports with an example. For this Power BI groups demonstration, we are going to use the SQL Data Source that we created in our previous article.
Please refer Connect to SQL Server article to understand the Power BI Data Source.
Create Groups in Power BI
To visually demonstrate this Power BI grouping technique, we will create a Pie chart. As you can see from the below screenshot, we created a Pie chart by dragging the Sales Amount column to the Values field and the Color to the Legend region.
NOTE: I suggest you refer to Create a Pie Chart and Format Pie Chart article to understand the steps involved in creating and formatting a pie chart.
If you observe the below screenshot, Data that we highlighted, such as Multi, NA, and Blue color products, are not performing well. So, let us group them
To perform grouping in Power BI, Please select the fields that you want to group, and right-click on it will open the context menu. Please select the Group option from the menu.
Once you click on the Group option, Power BI will automatically group those items as shown below. That’s it, we did the grouping.
If you observe closely, the Legend section is replaced by the Color group, and the color is placed in the details section.
TIP: By default, the Power BI Group option will group the selected items as one group and the remaining options as another group.
Let me remove the Color field from the Details section. Now you can see only two partitions in the Pie chart: one contains Blue, White, and NA colors, and the second partition contains the remaining colors.
Edit Power BI Group
Please select the group that you want to edit, and right-click on it will open the context menu. Select the Edit Groups option from it
Clicking the Edit Groups option will open the following window.
- Name: Specify the Group name
- Field: The field or Column that you used for grouping
- Group Type: List (group) or bin.
- Ungrouped values: Fields that are not grouped but available in this column.
- Groups and Members: List of groups and their members.
- Include Other Group: Do you want to place all the ungrouped members in the Other group? If so, checkmark this option.
Let me uncheck the Include Other groups. This will remove other group
Now you can see the pie chart that displays all the colors and one group that contains Blue, Multi, and NA colors.
Remove Power BI Group Members
To remove Power Bi group members, Please select the group member that you want to remove, and click ungroup button. For the demo purpose, we are removing the Blue colour.
Now you can see that the Blue color is removed and added under the ungrouped values.
And our pie chart displays all the colors and one group contains Multi and NA colors.
Rename a Group in Power BI
Double-click on the group that you want to rename, and provide a valid name. Let me rename it as White & Multi & NA
From the below screenshot, you can see that the group name has been renamed.
Add a Member to Groups in Power BI
Please select the group member that you want to add, and select the group as well. Next, click on the Group button.
For the demo purpose, we are adding White color to an existing group.
Now you can see the White color under the group
Create a New Group in Power BI
Please select the field for which you want to create a group, and click the group button. For the demo purpose, we are selecting the Yellow color.
Now you can see the new group.
Let me add a few more fields to it
Now you can see our pie chart has four colors, and they are Black, Red, and two groups.
Once you create a Group in Power BI, it will act like any other column or field. So, you can use it in N number of charts.
To demonstrate the same, we created a Column chart that shows the Country wise sales.
Next, we added the Color group in the legend section.
The second approach to create Groups in Power BI
Please select the field that you want to use as a group, and right-click on it will open the context menu. Select the New Group option from the context menu.
This will open the following window.
Sometimes, it will open the same window with a different option, as shown in the below screenshot. But, don’t worry, you can change the Group type from Bin to List.
Once you changed that property, you are good to go.