Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to filter a table based on user input?

Example - if a user inputs date (from table 1), I need to filter table 2 by displaying all the rows which have the range of date to date - 13. 

I created a slicer and now I take the value that is inputted in a measure. Table 2 has a date column. I'm just not sure how to display table 2 based on the measure to measure -13 values. 

Can you help me out?

  • Hi Anonymous ,

    No worries. Yes that can be done. 
    Just create a new measure like below :

     

    _val =

    var _sel = SELECTEDVALUE(dates[Dates])

    var _cond = if (MAX(SampleData[Date]) >= _sel-13 && MAX(SampleData[Date]) <= _sel , 1, 0)

    return
    _cond
     
    Then add this measure as a filter on the visual and set its value to 1

    Kind regards,

    Rohit


    Please mark this answer as the solution if it resolves your issue.
    Appreciate your kudos! 🙂

11 Replies

  • Hi Anonymous 

    Build one date table and connect them through date column like below. if you use the date table date column in slicer then table 2 results will automaticlly filtered for the selected date.

     

    Thanks

    Hari

    Did I answer your question? Then please mark my post as the solution.
    If I helped you, click on the Thumbs Up to give Kudos.


    My Blog :: YouTube Channel :: My Linkedin


  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you for replying. But doesn't that just filter the table such as the rows will represent the date selected?
    I want to display the rows that are in the range of date - 13 and date

  • Hi Anonymous,

    You can try something like this based on the sample data below:

    Table 1

    Table 2 


    Create a measure on Table 2 that takes the selected value from Table 1 and filters Table 2 using that.

    _Dates =

    var _sel = SELECTEDVALUE(dates[Dates])

    var _mindt =
    CALCULATE(
    min(SampleData[Date]),
    filter(SampleData,
    SampleData[Date] = _sel -13
    )
    )
    Return
    _mindt
     
     

    Kind regards,

    Rohit


    Please mark this answer as the solution if it resolves your issue.
    Appreciate your kudos! 🙂

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hey, thank you so much for replying! 
      I see what you've done. Is there anyway to get 14 - 27th dates in a table according to your example above?

      • rohit_singh's avatar
        rohit_singh
        Solution Sage

        Hi Anonymous ,

        No worries. Yes that can be done. 
        Just create a new measure like below :

         

        _val =

        var _sel = SELECTEDVALUE(dates[Dates])

        var _cond = if (MAX(SampleData[Date]) >= _sel-13 && MAX(SampleData[Date]) <= _sel , 1, 0)

        return
        _cond
         
        Then add this measure as a filter on the visual and set its value to 1

        Kind regards,

        Rohit


        Please mark this answer as the solution if it resolves your issue.
        Appreciate your kudos! 🙂