Link to home
Start Free TrialLog in
Avatar of Sonia Bowditch
Sonia BowditchFlag 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,
Thanks,
Infosec36
PQ-Test.xlsx
ASKER CERTIFIED SOLUTION
Avatar of Shums Faruk
Shums Faruk
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sonia Bowditch

ASKER

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.

Thanks,
InfoSec36
PQ-Test.xlsx
Sonia,
Over a month old, my guess is you have found a solution.
I think this is the Power Query M solution you seek:

let
    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}})
in
    #"Grouped Rows"

Open in new window

Perfect, thank you.