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
CharlotteCity12
Microsoft Employee
Microsoft Employee

Group and Count by Problem

I need to group by 'garage id' and 'block id' then list with count the Problem Sub Code.. see sample data  with results below:

 

 

CharlotteCity12_0-1646138804857.png

 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @CharlotteCity12 ,

 

Create a measure like below:-

Measure = 
    VAR _Table = 
        SUMMARIZE(
            'Table',
            [Garage id],
            'Table'[Blockid],
            'Table'[problem_subcode],
            "Count",COUNTROWS('Table')
        )
RETURN
    CONCATENATEX(_Table,[problem_subcode] & " " & "("&[Count]&")",", ")

Output:-

image.png

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
vojtechsima
Super User
Super User

Hi, @CharlotteCity12,
If you fancy your result in Power Query, here's the code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0ARL+IQFKsTpIAmbGLngETNG1YBUIdyYkgKLFDKQiPFwpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"garage id" = _t, blockid = _t, problem_subcode = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"garage id", Int64.Type}, {"blockid", Int64.Type}, {"problem_subcode", type text}}),
    #"Grouped Rows1" = Table.Group(#"Changed Type", {"blockid", "garage id", "problem_subcode"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows1", "text_formula", each [problem_subcode] &  " ("&Text.From([Count])&")"),
    #"Grouped Rows2" = Table.Group(#"Added Custom", {"garage id", "blockid"}, {{"problem_Chain", each [text_formula]}}),
    #"Extracted Values2" = Table.TransformColumns(#"Grouped Rows2", {"problem_Chain", each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    #"Extracted Values2"

vojtechsima_0-1646141611949.png

 

Please note, I tested it on manually put data, you have to modify the source if you want to see it working in your table.

 






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.
Samarth_18
Community Champion
Community Champion

Hi @CharlotteCity12 ,

 

Create a measure like below:-

Measure = 
    VAR _Table = 
        SUMMARIZE(
            'Table',
            [Garage id],
            'Table'[Blockid],
            'Table'[problem_subcode],
            "Count",COUNTROWS('Table')
        )
RETURN
    CONCATENATEX(_Table,[problem_subcode] & " " & "("&[Count]&")",", ")

Output:-

image.png

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.