Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Group records in multiple groups under one field/column in PBI

Hello,

 

I'm trying to create a new column called Product Type in Power BI which has 4 groups under it:

ShivrajB_0-1678399679964.png

 

Below are the records that I want to group in above mentioned groups so that I can create a donut chart showing the count of each individual group (i.e. 4 slices for 4 groups):

 

ShivrajB_2-1678399912195.png

 

For example: Row no. 2 should be grouped in group A since it has Tag A and also in group B since it has Tag B

The final counts that all 4 groups must have under Product Type (field to be dragged on canvas for donut chart) column should be:

 

ShivrajB_3-1678400074244.png

Is this possible in Power BI using DAX or any other available functionality?

Thanks in advance 🙂 

1 ACCEPTED SOLUTION
bolfri
Solution Sage
Solution Sage

Record IDTags

1Tag A, Tag B
2Tag A, Tag B, Tag C
3Tag B, Tag D
4Tag A, Tag C
5Tag C, Tag D
6Tag A

 

Product TypeTag

Group ATag A
Group BTag B
Group CTag C
Group DTag D

 

Records = COUNTROWS(fact_table)
 
Solution A (DAX) =
var tags = SELECTEDVALUE(dim_tags[Tag])
return CALCULATE(
    [Records],
    FILTER(fact_table,CONTAINSSTRING(fact_table[Tags],tags)
))
 
bolfri_0-1678402275647.png

 

 

Solution B (recommended):

let
Source = fact_table,
#"Split Column by Delimiter" = Table.SplitColumn(Source, "Tags", Splitter.SplitTextByDelimiter(", ", QuoteStyle.Csv), {"Tags.1", "Tags.2", "Tags.3"}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Split Column by Delimiter", {"Record ID"}, "Attribute", "Tags"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"})
in
#"Removed Columns"

bolfri_0-1678402772705.png

 

 

bolfri_1-1678402793462.png
bolfri_2-1678402803141.png

 

 

For solution B you can use simple Records measure and it will work faster with bigger amount of data.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks @bolfri for the both the solutions 🙂

I tired Soln. A and it worked as intended!

bolfri
Solution Sage
Solution Sage

Record IDTags

1Tag A, Tag B
2Tag A, Tag B, Tag C
3Tag B, Tag D
4Tag A, Tag C
5Tag C, Tag D
6Tag A

 

Product TypeTag

Group ATag A
Group BTag B
Group CTag C
Group DTag D

 

Records = COUNTROWS(fact_table)
 
Solution A (DAX) =
var tags = SELECTEDVALUE(dim_tags[Tag])
return CALCULATE(
    [Records],
    FILTER(fact_table,CONTAINSSTRING(fact_table[Tags],tags)
))
 
bolfri_0-1678402275647.png

 

 

Solution B (recommended):

let
Source = fact_table,
#"Split Column by Delimiter" = Table.SplitColumn(Source, "Tags", Splitter.SplitTextByDelimiter(", ", QuoteStyle.Csv), {"Tags.1", "Tags.2", "Tags.3"}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Split Column by Delimiter", {"Record ID"}, "Attribute", "Tags"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"})
in
#"Removed Columns"

bolfri_0-1678402772705.png

 

 

bolfri_1-1678402793462.png
bolfri_2-1678402803141.png

 

 

For solution B you can use simple Records measure and it will work faster with bigger amount of data.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors