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
EaglesTony
Post Prodigy
Post Prodigy

How do I group and sum certain columns ?

Hi,

 

  I have the following sample data:

 

Key          Status 

123          Ready

123          Ready

123          In Progress

123          Done

123          Cancelled

 

What I need is 

 

Key     Not-Done-Items    Done-Cancelled-Items

123     3                            2

 

Is there a way to group it this way and get a sum total ?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @EaglesTony ,

Please refer to the steps below:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyVtJRCkpNTKlUitXBxffMUwgoyk8vSi0uRhJ1yc9LReI6J+Ylp+bkpKaAxYyMTVAMgvDRDYKIwg2CcJEMigUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Key = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Key", Int64.Type}, {"Status", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Key"}, {{"Not-Done-Items", each Table.RowCount(Table.SelectRows(_, each [Status] = "Ready" or [Status] = "In Progress")), Int64.Type}, {"Done-Cancelled-Items", each Table.RowCount(Table.SelectRows(_, each [Status] = "Done" or [Status] = "Cancelled")), Int64.Type}})
in
    #"Grouped Rows"

vcgaomsft_0-1696485014938.png

Output:

vcgaomsft_1-1696485031723.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

5 REPLIES 5
Sandhya1234
Helper II
Helper II

Try it in the Matrix Table.

Sandhya1234_0-1696336095289.png

 

I was able to use a measure for this.

 

ItemsOpen = COUNTROWS(FILTER(Table1, Table1[STATUS] <> "Done" && Table1[STATUS] <> "Cancelled" ))
ItemsDone = COUNTROWS(FILTER(Table1, Table1[STATUS] = "Done" || Table1[STATUS] = "Cancelled" ))
 
This works, however when I try to replace nulls with 0, I get an circular reference.
 
First I have:
ItemsOpenChangeNulls = IF (ISBLANK([ItemsOpen]), 0, [ItemsOpen]) ==> This works
 
When I try to add the following, I get a circular reference error, not sure how to get around it ??????
ItemsNotOpenChangeNulls = IF (ISBLANK([ItemsDone]), 0, [ItemsDone])
Sandhya1234
Helper II
Helper II

@EaglesTony Please try the below measures:

1.Done-Items =
COUNTROWS(
    FILTER(
        'Table (4)',
        'Table (4)'[Ready] = "Done"
    )
)
 
2.Not-Done-Items =
COUNTROWS(
    FILTER(
        'Table (4)',
        'Table (4)'[Ready] = "Not Done"
    )
)
 
Sandhya1234_0-1696334817600.png

 

I think you mean [Status] = "Done" ?

 

Is there a way to do this in PowerQuery instead of DAX ?

Anonymous
Not applicable

Hi @EaglesTony ,

Please refer to the steps below:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyVtJRCkpNTKlUitXBxffMUwgoyk8vSi0uRhJ1yc9LReI6J+Ylp+bkpKaAxYyMTVAMgvDRDYKIwg2CcJEMigUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Key = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Key", Int64.Type}, {"Status", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Key"}, {{"Not-Done-Items", each Table.RowCount(Table.SelectRows(_, each [Status] = "Ready" or [Status] = "In Progress")), Int64.Type}, {"Done-Cancelled-Items", each Table.RowCount(Table.SelectRows(_, each [Status] = "Done" or [Status] = "Cancelled")), Int64.Type}})
in
    #"Grouped Rows"

vcgaomsft_0-1696485014938.png

Output:

vcgaomsft_1-1696485031723.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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