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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sequence by multiple columns

I need to be able to sequence my data using the current sequence - but totaling the "QuantityToBuild" column by grouping by the "Component" Column. 

 

So in otherwords I would need sequence 1 and 2 to be labeled as "1", Component "2128", and the QuantityToBuild "336". The go to sequence "2", Component "631", QuantityToBuild "224", and so on..

 

Here is my data currently as is:

SequenceItemNumberComponentQuantityToBuildDate
117821282245/11/2020 0:00
217921281125/11/2020 0:00
322706312245/11/2020 0:00
41822128565/11/2020 0:00
51832128565/11/2020 0:00
622716312245/11/2020 0:00
7848584891125/11/2020 0:00
8848484895045/11/2020 0:00
918121281685/11/2020 0:00
103108924905/11/2020 0:00
1164139452565/11/2020 0:00
123107924905/11/2020 0:00
1364129452565/11/2020 0:00
143109924305/11/2020 0:00

 

Here is how I would hope my data would look: 

 

SequenceComponentQuantityToBuildDate
121283365/11/2020 0:00
26312245/11/2020 0:00
321281125/11/2020 0:00
46312245/11/2020 0:00
584896165/11/2020 0:00
621281685/11/2020 0:00
7924905/11/2020 0:00
89452565/11/2020 0:00
9924905/11/2020 0:00
109452565/11/2020 0:00
11924305/11/2020 0:00
2 REPLIES 2
Greg_Deckler
Super User
Super User

Seems like you want to do a Group By on Component in Power Query. Then add a new Index column starting from 1. 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Like this. Only thing I don't understand is the logic of when to group and when not to group.

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZA9D8IgEIb/imE28e6AFhzVxcXE6NY4+MFgYls1dPDfez0S61BbFw6OJ8/xUhRqFx5NqM5BTdU6hnLTlKfw5MOyLu91FarI+21zrOI1vvb1orneLtxZHWNQh2mhkA+YO14JSQoZXu0McUZAMIE5gJAkpO9IROontWhy4JJpHHK2bXTUOW3WD1oB9TiYpdk4PjvntjPOpuKHArnEmA618MMqHodfv5S5fhLb/9EI7bWXR3r4QUoag218bywNxJcELM3HpTpJ6Q+pSVL/keo+6eEN", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Sequence", Int64.Type}, {"ItemNumber", Int64.Type}, {"Component", Int64.Type}, {"QuantityToBuild", Int64.Type}, {"Date", type datetime}}),
#"Grouped Rows" = Table.Group(#"Changed Type1", {"Component"}, {{"QuantityToBuild", each List.Sum([QuantityToBuild]), type number}, {"Date", each List.Max([Date]), type datetime}}),
#"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1)
in
#"Added Index"

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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