Forum Discussion
How to get selected month from date table
- 4 years ago
Hi Mahamood0218 ,
If your date is always the first of May on the year that you select, then the DAX for your card display would be something like this:
_selectionStartDate = VAR __year = SELECTEDVALUE(calendar[year]) RETURN FORMAT( DATE(__year, 05, 01), "dd-MM-yyyy" )Pete
- 4 years ago
Hi Mahamood0218 ,
No, the month in this example is fixed, it's only the year that is dynamic based on the selected slicer value.
If you want it to always default to the first of the current month, then you would use something like this:
_DateSelectedMonthStart = VAR __year = SELECTEDVALUE(DimDate[Year]) VAR __month = MONTH(TODAY()) RETURN FORMAT( DATE(__year, __month, 01), "dd-MM-yyyy" )Pete
Hi BA_Pete ,
Thanks for shared the code i have applied above code now it is working,
Note: I have another question in your code you had directly mentioned in DATE(Year,05,01) means month as mentioned directly ''05'' if i will login the same pbi report next month my dax function "DateSelectedMonthstart2" will shows like ''01-06-2022''?
Hi Mahamood0218 ,
No, the month in this example is fixed, it's only the year that is dynamic based on the selected slicer value.
If you want it to always default to the first of the current month, then you would use something like this:
_DateSelectedMonthStart =
VAR __year = SELECTEDVALUE(DimDate[Year])
VAR __month = MONTH(TODAY())
RETURN
FORMAT(
DATE(__year, __month, 01),
"dd-MM-yyyy"
)
Pete