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 date slicer then month on x axis should disply based on selections 

 

pbix : https://drive.google.com/file/d/1Bh7Lm1xUbIVmIp-RH2Z_-oPPSSDDhGWw/view?usp=drive_link

 

 

  • 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

6 Replies

  •  try use HASONEVALUE in the mensure, if has one value selected in field month or year, your mensure apoint to selected value, else show both values.

  • powerbiexpert22's avatar
    powerbiexpert22
    Impactful Individual

    Hi LeandroDeodato ,

    can you share more details, i tried to create measure however i need to display dimension values for month on x axis however measure returns only single value

     

  • powerbiexpert22's avatar
    powerbiexpert22
    Impactful Individual

    i am able to acheive it by creating calculated column, the problem is it is very difficult for user to navigate from year 9999 using calendar as shown in last screenshot

     

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      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