Forum Discussion

pradeepyadav921's avatar
pradeepyadav921
Frequent Visitor
2 years ago
Solved

DatePicker with a current default date

Hi all, 
I am creating a date picker with a dax

Calendar =
VAR Days = CALENDAR ( DATE ( 2024, 1, 1 ), DATE ( 2024, 12, 31 ) )
RETURN ADDCOLUMNS (
    Days,
    "Formatted Date", FORMAT([Date], "yyyy-mm-dd"),
    "Year", YEAR ( [Date] ),
    "Month Number", MONTH ( [Date] ),
    "Month", FORMAT ( [Date], "mmmm" ),
    "Year Month Number", YEAR ( [Date] ) * 12 + MONTH ( [Date] ) - 1,
    "Year Month", FORMAT ( [Date], "mmm yy" ),
    "Week Number", WEEKNUM ( [Date] ),
    "Week Number and Year", "W" & WEEKNUM ( [Date] ) & " " & YEAR ( [Date] ),
    "WeekYearNumber", YEAR ( [Date] ) & 100 + WEEKNUM ( [Date] ),
    "Is Working Day", NOT WEEKDAY([Date]) IN {1,7}
)
 Is there any way to to get default date as a today's date for selection like in this date picker for default value it should show today date

 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi pradeepyadav921 ,

    Regarding your question,if there is no future data in the dataset, you can do the following.

    1.Modify your DAX expression

     

     

    Calendar = 
    VAR Days = CALENDAR ( DATE ( 2024, 1, 1 ), TODAY() )
    RETURN ADDCOLUMNS (
        Days,
        "Formatted Date", FORMAT([Date], "yyyy-mm-dd"),
        "Year", YEAR ( [Date] ),
        "Month Number", MONTH ( [Date] ),
        "Month", FORMAT ( [Date], "mmmm" ),
        "Year Month Number", YEAR ( [Date] ) * 12 + MONTH ( [Date] ) - 1,
        "Year Month", FORMAT ( [Date], "mmm yy" ),
        "Week Number", WEEKNUM ( [Date] ),
        "Week Number and Year", "W" & WEEKNUM ( [Date] ) & " " & YEAR ( [Date] ),
        "WeekYearNumber", YEAR ( [Date] ) & 100 + WEEKNUM ( [Date] ),
        "Is Working Day", NOT WEEKDAY([Date]) IN {1,7}
    )

     

     

    2.Creating a slicer

    3.Final output

    Best Regards,
    Wenbin Zhou
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.