Forum Discussion
Group Based on Column Name
- 1 year ago
Hello
thanks for your suggestions.
Finally, I found this solution:
Header = Table.ColumnNames (#"Removed Columns2"),
SelectDollarColumns = List.Select(Table.ColumnNames(#"Removed Columns2"), each Text.Contains(_, "$")),
HeadersToRemove = List.Combine ({{"PHASE IN TOTAL MATURE VOLUMES"},SelectDollarColumns}),
HeaderDifference = List.Difference (Header,HeadersToRemove),Grouped_Table = Table.Group (
#"Removed Columns2",
HeaderDifference,
List.Transform(
SelectDollarColumns,
(l)=> {l, each List.Sum(Table.Column(_, l)), type nullable number}
)
)
Hello
here the link to the samples file:
and this is the function I would like to change:
#"Grouped Rows" = Table.Group(Source, {"Step", "Region"}, {{"TOTAL SALES", each List.Sum([#"PHASE IN TOTAL NET SALES [$]"]), type number}, {"TOTAL VOLUMES", each List.Sum([PHASE IN TOTAL MATURE VOLUMES]), type number}})
I was able to replace
{"Step", "Region"} in HeaderDifference
What I don't know is hot to replace
{{"TOTAL SALES", each List.Sum([#"PHASE IN TOTAL NET SALES [$]"]), type number}, {"TOTAL VOLUMES", each List.Sum([PHASE IN TOTAL MATURE VOLUMES]), type number}}
using the fact that I have the $ in the column header.
Probably this could appear not necessary, but this is only a sample file. The real file I have has a lot of columns, and I am looking for a way to be more rapid.
Thanks.
Hi Mic1979 , I have made some changes as per what I understood from your query. Do let me know if I have solved your query. Thanks!
https://docs.google.com/spreadsheets/d/1u3tdus_7axiZPNVX8WZWS8R6X_karx_G/edit?usp=sharing&ouid=104752674875039603034&rtpof=true&sd=true
- Mic19791 year agoPost Partisan
Thanks for your suggestion, but this is not what I was looking for.
I wanted to have:
#"Grouped Rows" = Table.Group(
Source,
HeaderDifference,
{something here to sum all the columns with $ in the column name}
Hoping this clarifies.
Thanks.
- SundarRaj1 year agoSuper User
Right Mic1979 , that clearly underlines the query. I might have misunderstood it earlier. Have a look at this one. Thanks!
https://docs.google.com/spreadsheets/d/1qEjIgfc7pLXfUU8vfT_oChhXlag0Z2-d/edit?usp=sharing&ouid=104752674875039603034&rtpof=true&sd=true