Forum Discussion
Date Measure
Hi NJ81858
Please try the formula
DATESYTD(DimDate[Date])
DATESYTD function (DAX) - DAX | Microsoft Learn
Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!
@ me in replies or I'll lose your thread.
Another option could be:
DATESBETWEEN=
var _lastdate = -> your code
var _firstdate = -> your code
RETURN
DATESBETWEEN(Dates[Date],var _firstdate,var _lastdate)
DATESBETWEEN function (DAX) - DAX | Microsoft Learn
Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!
@ me in replies or I'll lose your thread.
- NJ818583 years agoHelper IV
When I try the DATESYTD function and put it in a table, it gives me the error that says "Calculation error in measure: A table of multiple values was supplied where a single value was expected."
When I try the DATESBETWEEN function, it only returns the first value in the date table, that being, 1/1/2022, no matter what month I choose as my 'Selected Month' that the end date is supposed to be based on.
- Mikelytics3 years agoResident Rockstar
Hi NJ81858 ,
Yes, because you have to use it in combination with a calculation function. Because also with your current measure you want to calculate something else in the end, right?In the end it would look like this (example)
DATESBETWEEN and Calculation = DATESBETWEEN= var _lastdate = -> your code var _firstdate = -> your code RETURN CALCULATE( SUM(Table[Column]), DATESBETWEEN(Dates[Date],var _firstdate,var _lastdate) )If this dopes not help you then it would be helpful to get the full picture of want you intend to achive. You want a list of YTD dates but this is not the end right?
I assume you want to do a YTD calculation with a specific value. SO having a picture of the data model or some more contect would be good. 🙂
Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!
@ me in replies or I'll lose your thread.
- NJ818583 years agoHelper IV
Mikelytics This is my current data model:
I just want to apologize in advance for not being able to share my pbix file and masking all of the table names/fields, as there is highly sensitive data in the file. The highlighted table is obviously my date table, and all tables circled in blue report metrics that will use the custom date filter that this post is about. These metrics are more just reporting all values for the time period, instead of performing a calculation of sorts. The red circled tables need to be based on the same date table, but they only show a snapshot of the data from whatever the month selected is, hence why I want to have the user select only a month. In the end I hope that I can have the user select the month they want to see and the red circled tables will show only that month's data, and the blue circled tables will show all data from the beginning of the year to the end of the month selected.