Reputation: 11
I have this formula in a column in a gallery that returns a date.
Substitute(ThisItem.DateWorked,"0:00:00","")
This returns the date formatted in the column like this: 4/17/2023.
I would to be able to filter on this column using a dropdown with dates that are formatted in the same way.
If(IsBlank(ReconcileWorkdateStartDate.Value)=false, Filter(tbl_TimeSaved, Substitute(ThisItem.EmployeeNo,"Text","")=ReconcileWorkdateStartDate))
When I try to do this, I receive this error below:
Name is not valid. 'ThisItem isn't recognized. The Substitute function has some invalid arguments.
Upvotes: 0
Views: 1649
Reputation: 87318
ThisItem
is an operator that returns the item within a gallery (i.e., for each row). I'm assuming you have a gallery with the Items property set to some table, and one of the properties of that table is called 'DateWorked'. In this case, within the gallery you use ThisItem.DateWorked
to access that value for each row of your table.
If you are outside a gallery (such as trying to set the Items property of a dropdown), you don't need the ThisItem
identifier, as the property is already within scope of the Filter call:
Filter(
tbl_TimeSaved,
ReconcileWorkdateStartDate = ...
)
You can use the ThisRecord
specifier to access those scope values, but it is not necessary:
Filter(
tbl_TimeSaved,
ThisRecord.ReconcileWorkdateStartDate = ...
)
There is also another problem in your expression as shown in the question: 'ReconcileWorkdateStartDate' is seen both as a record (argument to IsBlank, with a property called 'Value') and a text value (being compared to the result of Substitute)
If(
IsBlank(ReconcileWorkdateStartDate.Value) = false,
Filter(
tbl_TimeSaved,
Substitute(ThisItem.EmployeeNo,"Text","") = ReconcileWorkdateStartDate
)
)
A related note: if the type of ThisItem.DateWorked is a date/time value not a string), then the best way to format it in a specific format is to use the Text function, such as Text(ThisItem.DateWorked, "m/d/yyyy")
- this way you don't have to rely on the default date-to-text conversion which may not give you the format the Substitute function is expecting, especially if there are users in other locales. If it is already a string then your option with Substitute is the best one.
Upvotes: 0