MGTexas123
New Member
- Joined
- Jan 1, 2020
- Messages
- 9
- Office Version
- 365
- Platform
- Windows
I am trying to create a Power Query with a parameter that what would perform the Table.Group function based on the parameter value. For example, if the parameter value Group by Region= "Yes", then sum up the sales and profits for each region. If the parameter value does not equal "Group by Region"="No", do not perform the group function. Here was the M code which produced the error message:
let
GroupByRegion="Yes",
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Profits", Int64.Type}, {"Sales", Int64.Type}}),
#"Conditional Parameter" = Table.AddColumn(#"Changed Type", "Custom", each if GroupByRegion="Yes" then Table.Group({"Sales Region"}, {{"Profits", each List.Sum([Profits]), type number}, {"Sales", each List.Sum([Sales]), type number}}) else 0)
in
#"Conditional Parameter"
When trying to run the query, I get this error message:
Expression.Error: 2 arguments were passed to function which expects between 3 and 5. Details: Pattern= Arguments=List
Any help on this would be greatly appreciated! Thanks!
let
GroupByRegion="Yes",
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Profits", Int64.Type}, {"Sales", Int64.Type}}),
#"Conditional Parameter" = Table.AddColumn(#"Changed Type", "Custom", each if GroupByRegion="Yes" then Table.Group({"Sales Region"}, {{"Profits", each List.Sum([Profits]), type number}, {"Sales", each List.Sum([Sales]), type number}}) else 0)
in
#"Conditional Parameter"
When trying to run the query, I get this error message:
Expression.Error: 2 arguments were passed to function which expects between 3 and 5. Details: Pattern= Arguments=List
Any help on this would be greatly appreciated! Thanks!