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

Formatting and Grouping rows

I have a chart that looks like this

marissaanj_0-1654097116804.png

I would like the rows to be grouped so their are subcategories. For example, this chart

marissaanj_1-1654097168549.png

For this example, I would like all the rows with the key word 'razor' to be under one category, and 'other' in another category

 

It would result in something like this 

 

RAZORS                  26          27

Disposable razors   4             5

razor                      12          14 

razors                    10            8

OTHER                   3             3

shampoo                2             1

shave                      1             2

 

Help is greatly appreciated

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsksLsgvTkzKSVUoSqzKLypW0lEyAWJTpVidaCWwEJBnaAQiTBQQgiB1hgZAwgIsVpyRmFuQnw/kg1XCxMpSwTyQaGwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.Contains( Text.Upper([Column1]),"RAZOR") then "RAZORS" else "OTHER")
in
    #"Added Custom"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsksLsgvTkzKSVUoSqzKLypW0lEyAWJTpVidaCWwEJBnaAQiTBQQgiB1hgZAwgIsVpyRmFuQnw/kg1XCxMpSwTyQaGwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.Contains( Text.Upper([Column1]),"RAZOR") then "RAZORS" else "OTHER")
in
    #"Added Custom"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

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.