Hi @nottheOther ,
Could you please share a bit more about your scenario?
Do you want to sort your Data Table records based on the selected column name () from the Dropdown box?
I have made a test on my side, please consider take a try with the following workaround:
1. Add a Dropdown control in your app, set the Items property to following:
["date", "ID", "Status", ...] // Specify the availble columns from your data source here
Note: Currently, the SortByColumns function could not be used to sort by a complex type column, e.g. LookUp, Choice, Person, etc.
2. Set the Items property of the Data Table to following:
If(
Dropdown2_2.DisplayMode = Disabled && Dropdown2_3.DisplayMode = Edit,
If(
Dropdown1.Selected.Value = "date",
Sort(Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result), date, Descending),
Dropdown1.Selected.Value = "ID",
Sort(Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result), ID, Descending),
Dropdown1.Selected.Value = "Status",
Sort(Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result), Status, Descending),
...
...
)
)
If the Status is a Choice type column in your SP list, please consider modify above formula as below:
If(
Dropdown2_2.DisplayMode = Disabled && Dropdown2_3.DisplayMode = Edit,
If(
Dropdown1.Selected.Value = "date",
Sort(Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result), date, Descending),
Dropdown1.Selected.Value = "ID",
Sort(Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result), ID, Descending),
Dropdown1.Selected.Value = "Status",
Sort(Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result), Status.Value, Descending), // Modify formula here
...
...,
)
)
In addition, you could also consider create each button for these columns you want to sort by in your app, then set the OnSelect property of the "sort by date" button to following:
Set(SortColumn, "date")
set the OnSelect property of the "sort by ID" button to following:
Set(SortColumn, "ID")
set the OnSelect property of the "sort by Status" button to following:
Set(SortColumn, "Status")
Then set the Items property of the Data Table to following:
If(
Dropdown2_2.DisplayMode = Disabled && Dropdown2_3.DisplayMode = Edit,
If(
SortColumn = "date",
Sort(Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result), date, Descending),
SortColumn = "ID",
Sort(Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result), ID, Descending),
SortColumn = "Status",
Sort(Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result), Status, Descending),
...
...,
Filter(SharePointListSource, ColumnName = Dropdown2_3.Selected.Result) // If SortColumn variable is blank, do not sort your data table
)
)
Please consider take a try with above solution, then check if the issue is solved.
Best regards,