Forum Discussion

powerbiexpert22's avatar
powerbiexpert22
Impactful Individual
2 years ago
Solved

Default YTD

i want to display YTD months and year  ( from jan 2024 until jul 2024) on x axis in line chart by default if there are no selections made on date range slicer  if there are any selections made on da...
  • Anonymous's avatar
    Anonymous
    2 years ago

    LeandroDeodato Thanks for your contribution on this thread.

    Hi powerbiexpert22 ,

    You can follow the steps below to get it, please find the details in the attachment.

    1. Create a measure as below 

    IsSlicerFiltered = 
    VAR _year =
        SELECTEDVALUE ( 'Date'[Year] )
    VAR _month =
        SELECTEDVALUE ( 'Date'[MonthNo] )
    RETURN
        IF (
            ISFILTERED ( 'Date'[Date] ),
            1,
            IF (
                _year = YEAR ( TODAY () )
                    && _month >= 1
                    && _month <= MONTH ( TODAY () ),
                1,
                0
            )
        )

    2. Apply the visual-level filter with the condition(IsSlicerFiltered is 1) on the line chart

    Best Regards