Forum Discussion
Summing Columns Based on Column Header String
- 4 years ago
The new column would like like:
List.Sum(List.Transform(List.Select(Record.FieldNames(_), each Text.StartsWith(_, "2021") or Text.StartsWith(_, "2022")), (name) => Record.Field(_, name)))
Alterativly,
1. Transpose the table
2. select rows where the first column starts with 2021 or 2022
3. transpose the table back.
The new column would like like:
List.Sum(List.Transform(List.Select(Record.FieldNames(_), each Text.StartsWith(_, "2021") or Text.StartsWith(_, "2022")), (name) => Record.Field(_, name)))
Alterativly,
1. Transpose the table
2. select rows where the first column starts with 2021 or 2022
3. transpose the table back.
- jaiken4 years agoFrequent Visitor
Very nice... I wrote it this way in order to get a 2022 Column and it works very nicely:
List.Sum(List.Transform(List.Select(Record.FieldNames(_), each Text.StartsWith(_, "2022")), (name) => Record.Field(_, name)))
Thank you for your fast work.