Hi @jf7 ,
Regarding the formula that you mentioned, I think there is something wrong with it. When you use a variable name as Sort column in the SortByColumns function, the SortByColumns function would not recognize the variable as a valid column in your data source.
If you want to sort your records based on different columns against a variable, I afraid that there is no direct way to achieve your needs. As an fixed solution, please check and see if the following thread solution would help in your scenario:
https://powerusers.microsoft.com/t5/Building-Power-Apps/Sort-sharepoint-datatable/m-p/403121
Please modify your formula as below:
If(
Sorting = "Column1",
SortByColumns(
Filter(EDMS, Publish="false"),
"Column1", // specify corresponding column name from your data source here, wrapped with double quotes
If(SortDescending1, Ascending , Descending)
),
Sorting = "Column2",
SortByColumns(
Filter(EDMS, Publish="false"),
"Column2", // specify corresponding column name from your data source here, wrapped with double quotes
If(SortDescending1, Ascending , Descending)
),
Sorting = "Column3",
SortByColumns(
Filter(EDMS, Publish="false"),
"Column3", // specify corresponding column name from your data source here, wrapped with double quotes
If(SortDescending1, Ascending , Descending)
),
...
...
)
Note: Please do not add the If function inside your Filter function or SortByColumns function, otherwise, you would still cause Delegation warning issue in your formula.
Regards,