Avatar of Sonia Bowditch
Sonia Bowditch
Flag for Guernsey asked on

Power Query Grouping By

I have a Power Query from a table.  As I am still learning about what Power Query can do I am struggling with Grouping.

What I am trying to do is:

Group by Customer, by level 1, show the earliest date requested for all categories (in this case 2), lastest date updated by level 1, total quantity received by level 1.

If I can get help with putting together this bit, I will be able to work out everything else I need to do with this Power Query table.

I have attached a file containing test data.

I appreciate any help you can give me,
Microsoft OfficeMicrosoft ExcelSpreadsheets

Avatar of undefined
Last Comment
Sonia Bowditch

8/22/2022 - Mon
Shums Faruk

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Sonia Bowditch

Hello Shums,

Thanks for getting back to me.

I have attached an example of what I am trying to achieve with the Power Query, shown on Sheet 2.  The area I am struggling with is the dates as I can work out to do total of fields.


Over a month old, my guess is you have found a solution.
I think this is the Power Query M solution you seek:

    Source = Excel.CurrentWorkbook(){[Name="PQ_Test"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"customer", type text}, {"level_1", type text}, {"date_request", type datetime}, {"dt_created", type datetime}, {"last_updated", type datetime}, {"price", type number}, {"net_value", type number}, {"vat_value", type number}, {"total_value", type number}, {"qty_req", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"customer", "level_1"}, {{"Earliest date_request", each List.Min([date_request]), type datetime}, {"Last last_updated", each List.Max([last_updated]), type datetime}, {"Sum qty_req", each List.Sum([qty_req]), type number}})
    #"Grouped Rows"

Open in new window

Sonia Bowditch

Perfect, thank you.
Your help has saved me hundreds of hours of internet surfing.