Forum Discussion
Help with date filters
Hi, I'm working with different filters through measurements using dates, and I'm constantly getting the following error that I can't fix: "The expression refers to multiple columns. You cannot convert multiple columns to a scalar value."
How can it be solved? Can this have to do with working with a date column?
I leave an example of one of the measures I am working on:
Then, is there any way to apply this type of filters directly on a graph? For example, having a stacked bar chart filtered by measurement deadlines. Thank you!!
6 Replies
- amitchandak
Super User
The meausre would be like
countrows(FILTER('Tasks', DATESBETWEEN('Tasks'[TaskDate], [FechaDesde], [FechaHasta])))
You can use measure in visual level filter
- Syndicate_Admin
Administrator
Hi, thanks for your answer, I was trying to apply it to my table and graph but I get the following error that I can't fix: "A multi-valued table was provided where a single value was expected."
How could I fix it?
I am using a calendar table to be able to filter my data, since the original table had duplicate dates and this was also causing me problems. Thank you!- AnonymousNot applicable
Hi Syndicate_Admin ,
Please share a sample file with me and show me a screenshot with the result you want. This will make it easier for me to find the solution.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Hi Syndicate_Admin ,
As far as I know, DATESBETWEEN() will return a column instead a scalar value. However, measure need to be a aggregation value, so your measure will return error.
For reference: DATESBETWEEN
Returns a table that contains a column of dates that begins with a specified start date and continues until a specified end date.
This function is suited to pass as a filter to the CALCULATE function. Use it to filter an expression by a custom date range.
According to your statement, I think you want to return all taskdates in date range. Here I suggest you to create a table visual with taskdates, then create a measure as a visual level filter.
Filter = IF ( MAX ( Tasks[TaskDate] ) IN DATESBETWEEN ( Tasks[TaskDate], [FechaDesde], [FechaHasta] ), 1, 0 )In my sample, FechaDesde = 2022/10/21 and FechaHasta = 2022/11/01, TaskDate is whole 2022. Add this measure as a visual level filter and set it to show items when value = 1.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Syndicate_Admin
Administrator
Thank you very much for your answer, I think this solution could work, I am trying to apply it but I am having a problem for having duplicate task dates, it tells me that this is not allowed:
Is there a way to fix it?