The title I've given this topic is probably not as good as it might be...hopefully I can explain better here.
I have a table, Contingency, in Power Query. It's pretty straightforward with Project Number, Project Name and then multiple columns of Forecast figures over a number of years...with each year split into 13 periods. So 13 columns per year and lets say 10 years worth of data = 130 columns. I need to sum those figures for each particular year...so if the Column Header starts with 2024 then sum those columns. Sounds simple, thought I knew what I was doing...but I can't make it work for the life of me...even the 'all knowing' CHAT GPT comes up with code which errors out.
An important consideration is that the source of the table does not output a column if that column is empty. So although you would expect Period 1 to Period 13 to be created if Period 2 and 3 are empty then they columns will not be created so you have 11 rather than 13 for that year.
Here is one of many attempts I've made, one of the more simpler ones at least:
List.Sum(Table.SelectColumns(Contingency, {"2023-2024 P01", "2023-2024 P02", "2023-2024 P03", "2023-2024 P04", "2023-2024 P05", "2023-2024 P06", "2023-2024 P07", "2023-2024 P08", "2023-2024 P09", "2023-2024 P10", "2023-2024 P11", "2023-2024 P12", "2023-2024 P13"}, MissingField.Ignore))
Any ideas?
Thanks in advance.