Forum Discussion
DAX date today query
Hello everyone,
Within a step in a flow to Run a query against I dataset, I wish to just retrieve items from a column called ETD where the date is "today" but I am getting an error when I try to test this, so as a novice I expect the format is not quite right:
I think this is the part in question in the query:
VAR __DS0FilterTable4 =
KEEPFILTERS (
FILTER (
ALL ('SDT Clarity Tasks'[ETD] ),
'SDT Clarity Tasks'[ETD] = (Today ()),
)
Please can someone point me in the right direction ?
Many thanks
- Anonymous1 year ago
Many thanks, this helped me to fix it.
Please accept the correct answer as a Solution.
Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!
10 Replies
- saud968Memorable Member
The issue might be with the syntax of the Today() function. In DAX, the correct function to get today’s date is TODAY() without any parameters. Here’s how you can adjust your query:
VAR __DS0FilterTable4 =
KEEPFILTERS (
FILTER (
ALL ('SDT Clarity Tasks'[ETD]),
'SDT Clarity Tasks'[ETD] = TODAY()
)
)This should correctly filter the ETD column to only include rows where the date is today.
If you continue to experience issues, make sure that the ETD column is formatted as a date and that there are no time components in the date values. If ETD includes time, you might need to use the TRUNC function to compare only the date part:
VAR __DS0FilterTable4 =
KEEPFILTERS (
FILTER (
ALL ('SDT Clarity Tasks'[ETD]),
TRUNC('SDT Clarity Tasks'[ETD]) = TODAY()
)
)This will ignore the time part and compare only the date.
Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!- AnonymousNot applicable
Many thanks, this helped me to fix it.
- saud968Memorable Member
Please accept the correct answer as a Solution.
Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!
- muhammad_786_1Solution Supplier
Hy Anonymous
You can retrieve items from the ETD column where the date is "today" by using this simple solution in Power BI. You can just apply a visual-level filter using Relative Date Filtering.Best Regards,
Muhammad Yousaf
If this post helps, then please consider "Accept it as the solution" to help the other members find it more quickly.
- AnonymousNot applicable
Thanks for your suggestion.
- rohit10191Frequent Visitor
Hi Anonymous ,
Try adding the EVALUATE and RETURN keywords as shown below. Also, your syntax for the filter query seems incorrect. Please try this code :
EVALUATEVAR __DS0FilterTable4 =
KEEPFILTERS (
FILTER (
ALL ('SDT Clarity Tasks'[ETD] ),
'SDT Clarity Tasks'[ETD] = Today ()
)
)
RETURN
__DS0FilterTable4 - rohit10191Frequent Visitor
Hi Anonymous ,
Try adding the EVALUATE and RETURN keywords as shown below. Also, your syntax for the filter query seems incorrect. Please try this code :
EVALUATEVAR __DS0FilterTable4 =
KEEPFILTERS (
FILTER (
ALL ('SDT Clarity Tasks'[ETD] ),
'SDT Clarity Tasks'[ETD] = Today ()
)
)
RETURN
__DS0FilterTable4- AnonymousNot applicable
Thank you
- AnonymousNot applicable
Hi Anonymous ,
I create a table as you mentioned.
It looks like the KEEPFILTERS function is causing an issue because it needs to be used within CALCULATE or CALCULATETABLE.
So I think you can change your codes.
EVALUATE VAR __DS0FilterTable4 = CALCULATETABLE ( FILTER ( ALL ( 'SDT Clarity Tasks'[ETD] ), 'SDT Clarity Tasks'[ETD] = TODAY () ) ) RETURN __DS0FilterTable4Then you will get what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
That's great, thank you