Forum Discussion

LucianoB_'s avatar
LucianoB_
Frequent Visitor
3 years ago
Solved

Add a date filter following a Field Parameters slicer selection.

Hi,

 

I have a table with 2 dates and a few measurements:

 

Date 1             Date 2              Measuremente
01/01/202312/01/202210
01/02/202301/01/202323
01/03/202302/01/202345

 

I want a dynamic X-axis, so I created a Field Paramenter with Date 1 and Date 2:

 

Date 1 or Date 2 = {
    ("Date 1", NAMEOF('Table'[Date 1].[Month]), 0),
    ("Date 2", NAMEOF('Table'[Date 2].[Month]), 1)
}
 
Slicer works as expected, however after selecting one of the options (Date 1 or Date 2), I would like the date to show only 2023 and forward.
 
By using the table above it should filter like this:
 
Day 1 selected
Date 1              Date 2              Measuremente
01/01/202312/01/202210
01/02/202301/01/202323
01/03/202302/01/202345

 

Day 2 selected

Date 1                 Date 2                  Measuremente
01/02/202301/01/202323
01/03/202302/01/202345

 

 

Appreciate your help.

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi LucianoB_ ,

     

    You can create a measure as a visual-level filter.

    Measure =
    SWITCH (
        SELECTEDVALUE ( Parameter[Parameter Fields] ),
        "'Table'[Date 1]", IF ( YEAR ( MAX ( 'Table'[Date 1] ) ) = 2023, 1 ),
        "'Table'[Date 2]", IF ( YEAR ( MAX ( 'Table'[Date 2] ) ) = 2023, 1 )
    )
    

    Put this measure into the filters, set up show items when the value is 1.

    Here're the results.

     

    Best Regards,

    Stephen Tao

     

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

    • LucianoB_'s avatar
      LucianoB_
      Frequent Visitor

      Thank you so much Anonymous, I realy appreciate your help.

       

      That worked very well with the full date, however I am using Month on the Paramenter Field ('Table'[Date 1].[Month]), and the filter is returning blank.

       

      I took your sample file and added a 2nd Parameter:

       

       

      Parameter2 = {
          ("[Date 1].[Month]", NAMEOF('Table'[Date 1].[Month]), 0),
          ("[Date 2].[Month]", NAMEOF('Table'[Date 2].[Month]), 1)
      }

       

       

       

      Here are the results:

       

       

      This is what I am trying to achive:

       

      Thank again for your help.