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
Just2431
Helper I
Helper I

Help with the count

Hi! 

I have a test table, the first column has document id that it duplicates and the same document can go throught several diffrent operations. I would like to see how many diffrent operations the same document goes thrught and still keep the time for each operation. How can i achive this?

 

Just2431_0-1720701589564.png

 

Thank you for your help!

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@Just2431 If you had posted your sample data as text, I could have given you a working PBIX file. So, instead, I'll try to explain the process. In PQ Editor, do a Group By operation and use Doc id as the grouping. Use Advanced. Add a Count aggregation as well as an aggregation that keeps all rows. Now, expand the all rows column for your operation_name and time. Now you will have a new column that provides the count of operations for each doc id on each row and also preserve the rest of your data.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

dufoq3
Super User
Super User

Hi @Just2431, try this:

 

dufoq3_0-1720715977141.png

dufoq3_2-1720716116677.png

 

Result

dufoq3_3-1720716134117.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnAPV9JR8snMy87MSweyDJVidWCiSfkVEEFjJMHkotTEklQgwwRZMDEnuRhImyKJpeaVpBZB9BuBhb19ojyw2AUVhluGohhuG4pamHXGyIJI9qEoTiwoKMovS8yBq3d0cgayCxPhCiECaA6ACMJsMtIDei0WAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Doc id" = _t, operation_name = _t, time = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"time", type number}}, "en-US"),
    GroupedRows = Table.Group(ChangedType, {"Doc id"}, {{"All", each _, type table [Doc id=nullable text, operation_name=nullable text, time=nullable number]}, {"Operations", each Table.RowCount(_), Int64.Type}}),
    ExpandedAll = Table.ExpandTableColumn(GroupedRows, "All", {"operation_name", "time"}, {"operation_name", "time"})
in
    ExpandedAll

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

2 REPLIES 2
dufoq3
Super User
Super User

Hi @Just2431, try this:

 

dufoq3_0-1720715977141.png

dufoq3_2-1720716116677.png

 

Result

dufoq3_3-1720716134117.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnAPV9JR8snMy87MSweyDJVidWCiSfkVEEFjJMHkotTEklQgwwRZMDEnuRhImyKJpeaVpBZB9BuBhb19ojyw2AUVhluGohhuG4pamHXGyIJI9qEoTiwoKMovS8yBq3d0cgayCxPhCiECaA6ACMJsMtIDei0WAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Doc id" = _t, operation_name = _t, time = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"time", type number}}, "en-US"),
    GroupedRows = Table.Group(ChangedType, {"Doc id"}, {{"All", each _, type table [Doc id=nullable text, operation_name=nullable text, time=nullable number]}, {"Operations", each Table.RowCount(_), Int64.Type}}),
    ExpandedAll = Table.ExpandTableColumn(GroupedRows, "All", {"operation_name", "time"}, {"operation_name", "time"})
in
    ExpandedAll

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Greg_Deckler
Community Champion
Community Champion

@Just2431 If you had posted your sample data as text, I could have given you a working PBIX file. So, instead, I'll try to explain the process. In PQ Editor, do a Group By operation and use Doc id as the grouping. Use Advanced. Add a Count aggregation as well as an aggregation that keeps all rows. Now, expand the all rows column for your operation_name and time. Now you will have a new column that provides the count of operations for each doc id on each row and also preserve the rest of your data.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.