
Announcements
The dates in my data table are not sorting correctly. I want the newest dates on top. When I select 10/24 for instance, data from 9/27 appears above data from 10/18.
This is the formula I'm using.
SortByColumns
(
Filter
(
'Data'
,DateTimeValue(ProductionTime) < DatePicker1.SelectedDate
&& DateTimeValue(ProductionTime) > DateAdd(DateTimeValue(DatePicker1.SelectedDate),-2,Months)
)
,"ProductionTime"
,Descending
)
The SortByColumns is sorting properly: "ProductionTime" is still considered text/single line of text because you are using the DateTimeFunction inside the Filter() function which still returns just a single line of text. The DateTimeFunction is only getting the correct records and not actually transforming ProductionTime into a date that can be sorted.
Use AddColumns to transform the text column type ProductionTime into a date column type, for example:
AddColumns('Data',"_ProductionTimeDATE",DateTimeValue(ProductionTime))This gives you an extra column that is a date:
The solution is to replace 'Data' from your original code with the AddColumns formula above:
SortByColumns (
Filter (
AddColumns('Data',"_ProductionTimeDATE",DateTimeValue(ProductionTime))
,DateTimeValue(ProductionTime) < DatePicker1.SelectedDate
&& DateTimeValue(ProductionTime) > DateAdd(
DatePicker1.SelectedDate,
-2,
Months
)
)
,"_ProductionTimeDATE"
,Descending
)Now the data table sorts properly (using the list testChoices instead of 'Data'):