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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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