Power Query (Get&Transform)

hailstorm

New Member
Joined
Sep 14, 2019
Messages
34
Hello there

A few weeks ago i asked a question and a nice member of this website told me about this tool in excel, it solved my problem, but since i cannot send private message, here i'm again.

I have this very long sheet filled with more than 160.000 lines of data ( 2.923 products ), so i what do i need? I'd like to have the number of days at the end of each month and the number of sells of all products, example.

my sheet have 03 columns, a=date,01/01/2020 * b=product,chocolate * c=quantity sold,01 .... the entire sheet is registered with 01 sell per line. So what i tried was this.

Code:
= Table.Group(#"Tipo Alterado", {"product"}, {{"Count", each List.Sum([quantity sold]), type number}, {"january", each Table.RowCount(_), type number}, {"february", each Table.RowCount(_), type number}, {"march", each Table.RowCount(_), type number}})

The counting repeat to all the new columns that it's created, it's only sum all the 01.

Is there a way to Power Query detect each month and sum in a different column?

Thanks.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
SSS.jpg
 
Upvote 0
is that what you want?

based on your not representative, poor example (incomplete picture!)

grpt.jpg
 
Upvote 0
for incomplete example above...
Code:
// Table2
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}, {"product", type text}, {"quantity sold", Int64.Type}}),
    #"Inserted Month Name" = Table.AddColumn(#"Changed Type", "Month Name", each Date.MonthName([date]), type text),
    #"Grouped Rows" = Table.Group(#"Inserted Month Name", {"product", "Month Name"}, {{"Q sold", each List.Sum([quantity sold]), type number}, {"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Month", each List.Distinct(Table.Column([Count],"Month Name"))),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Month", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Added Custom1" = Table.AddColumn(#"Extracted Values", "QS", each List.Distinct(Table.Column([Count],"quantity sold"))),
    #"Extracted Values1" = Table.TransformColumns(#"Added Custom1", {"QS", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values1",{"Count"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Month]), "Month", "QS", List.Count)
in
    #"Pivoted Column"
so adapt to your needs
 
Upvote 0
for incomplete example above...
Code:
// Table2
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}, {"product", type text}, {"quantity sold", Int64.Type}}),
    #"Inserted Month Name" = Table.AddColumn(#"Changed Type", "Month Name", each Date.MonthName([date]), type text),
    #"Grouped Rows" = Table.Group(#"Inserted Month Name", {"product", "Month Name"}, {{"Q sold", each List.Sum([quantity sold]), type number}, {"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Month", each List.Distinct(Table.Column([Count],"Month Name"))),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Month", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Added Custom1" = Table.AddColumn(#"Extracted Values", "QS", each List.Distinct(Table.Column([Count],"quantity sold"))),
    #"Extracted Values1" = Table.TransformColumns(#"Added Custom1", {"QS", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values1",{"Count"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Month]), "Month", "QS", List.Count)
in
    #"Pivoted Column"
so adapt to your needs

Thanks, again.
It worked.
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,749
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top