Jerry Sullivan
MrExcel MVP
- Joined
- Mar 18, 2010
- Messages
- 8,787
I have this M Code that returns the desired table:
I'd like to replace [FY19] with an expression that returns the same List, using the Text "FY19" which can be replaced with a parameter instead of hard-coding a specific year.
I've tried this syntax but it returns a list of error values
Thanks!
Code:
let
Source = Table.FromRecords(
{
[ProjID= "P1", FY19 = 1, FY20 = 1],
[ProjID= "P1", FY19 = 11, FY20 = 0],
[ProjID= "P2", FY19 = 2, FY20 = 12],
[ProjID= "P3", FY19 = 3, FY20 = 13],
[ProjID= "P4", FY19 = 4, FY20 = 14]
}),
#"Grouped Rows" = Table.Group(Source, "ProjID", {
{"Year 1", each List.Sum([COLOR="#FF0000"][FY19][/COLOR]), type number},
{"Year 2", each List.Sum([FY20]), type number}
})
in
#"Grouped Rows"
I'd like to replace [FY19] with an expression that returns the same List, using the Text "FY19" which can be replaced with a parameter instead of hard-coding a specific year.
I've tried this syntax but it returns a list of error values
Code:
#"Grouped Rows" = Table.Group(Source, "ProjID", {
{"Year 1", each List.Sum(
[COLOR="#FF0000"] Table.SelectColumns(
Table.SelectRows(Source, _ = _), "FY19")[/COLOR]
), type number},
{"Year 2", each List.Sum([FY20]), type number}
})
Thanks!
Last edited: