Forum Discussion

george1's avatar
george1
Frequent Visitor
1 year ago
Solved

Date Picker slicer with relative date

Hello, I need one help. Anonymous , visheshjain , collinq , MiquelPBI , mariussve1  I have data like this, here I have  4 different date options:     Now without changing the style of the d...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Thanks for the reply from  DataNinja777 and MiquelPBI  , please allow me to provide another insight:

    Hi, george1 

    Based on my testing, parameters cannot be converted to the relative time type in a slicer. Therefore, your slicer must be derived from one of the columns in your data table. This is likely why you are encountering errors, as one of your slicers is derived from parameters, while the relative time type is from a fixed column.

     

    I have provided an alternative solution for you:

     

    1.Firstly, create the following measure:

    MEASURE = 
    VAR diff = 10
    VAR selectid =
        MAX ( 'Parameter'[Parameter Order] )
    VAR column1d =
        CALCULATE ( MAX ( 'Table'[Column1] ), ALLSELECTED ( 'Table' ) )
    VAR column2d =
        CALCULATE ( MAX ( 'Table'[Column2] ), ALLSELECTED ( 'Table' ) )
    RETURN
        SWITCH (
            TRUE (),
            selectid = 0,
                IF ( MAX ( 'Table'[Column1] ) >= column1d - diff, 1, 0 ),
            selectid = 1,
                IF ( MAX ( 'Table'[Column2] ) >= column2d - diff, 1, 0 ),
            1
        )

    2.Secondly, apply the measure to the visual object:

     

     

    3.Here's my final result, which I hope meets your requirements.

     

    Please find the attached pbix relevant to the case.

     
    Of course, if you have any new ideas, you are welcome to contact us.
     

    Best Regards,

    Leroy Lu

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