Hi Melissa, thanks so much for your help. It worked almost perfectly. I amended the YearVariable as you showed it, like this
= if YEARSELECTIONTABLE{0}[Year]=“All”
then List.Transform( List.Select( YEARSELECTIONTABLE[Year], each _ <> “All”), Number.From )
else List.Transform({YEARSELECTIONTABLE{0}[Year]},Number.From)
and I updated the filter like this
= Table.SelectRows(#“Renamed Year”, each List.Contains( YearVariable, [OrderDate.Year] ))
and it worked great as long as my YEARSELECTIONTABLE contains an actual year.
When YEARSELECTIONTABLE contains “All” however, I got an error message to say "DataFormatError, We could not convert to a number. Details: “All”
So I think I need to do something more to line 2 in the statement above.
A thought that occurred to me is there is only ever one selected parameter in the table YEARSELECTIONTABLE, since this table is fed from a (data validation) list. The user selects one parameter from the drop down which might be “All” or it might be a year. so I first wondered at first if that was the issue and if I referred to another table in line 2 with all the available parameters / years that it might work.
So on line 2 of the statement I substituted YEARSELECTIONTABLE (which contains the single selected parameter, “All” or a year) with ALLYEARSTABLE (which contains all possible parameters ie “All” or 2021, 2022 etc). Both tables are formatted as text.
This was my new version:-
= if YEARSELECTIONTABLE{0}[Year]=“All”
then List.Transform( List.Select( ALLYEARSTABLE[Year], each _ <> “All”), Number.From )
else List.Transform({YEARSELECTIONTABLE{0}[Year]},Number.From)
However I got the same error message about not being able to convert All to a number. So I guess that was not the answer!!
If you have any more tips I will gratefully try them out.