Forum Discussion

aatish178's avatar
aatish178
Icon for Helper IV rankHelper IV
2 years ago
Solved

Dynamic filtering of data based on user selected date

Hie All,

I have 2 date columns from 2 different tables as shown below:

Table1:

Date for filtering
2024-04-18
2024-04-10

Here the single select setting is applied to this date column

 

Table2:

Date of AdmissionRollNo
2024-04-2065443
2024-04-1924231
2024-04-1612313
2024-04-1512123
2024-04-1435342
2024-04-1342143
2024-04-1223342
2024-04-1115432
2024-04-1017282
2024-04-0911132
2024-04-0823121
2024-04-0712653

 

What I want:

Senario1: I want to show only those dates in table2 which are less than current selected date by user from table1:

for example if user selects 2024-04-18 from table1 then dates less than 2024-04-18 should be visible in the table2(2024-04-16 to 2024-04-07) along with roll no.,

 

Scenario2: and if user selects 2024-04-10 from table1 then dates from 2024-04-09 to 2024-04-07 should be visible in table2 along with its respective rollno.

 

Once this is achieved, then based on filtered result I want to calculate max of roll no., for e.g., for scenario 1 below should be the final result:

2024-04-1342143

because 42143 is the max of roll no for the filtered result of scenario1

 

same for scenario 2 I want to calcualte max of roll no. from the filtered result., that means below record should come as output:

2024-04-0823121

 

The result should behave dynamically based on different Table1 date selections., here for sample I have shown only 2 dates in table1.

 

Can someone please help in achiving the dynamic result for above use case?

Ashish_Mathur quantumudit quantumudit1 gmsamborn Anonymous 

 

Regards,

Aatish

10 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi aatish178 ,

     

    1. Create a table that is not related to the original table and use it as a slicer.

    Table3 =
    DISTINCT('Table1'[Date for filtering])

     

    2. Create a measure to filter the date.

    MEASURE = 
    VAR _test =
        CALCULATE (
            MAX ( 'Table2'[Date of Admission] ),
            FILTER (
                ALL ( Table2 ),
                'Table2'[Date of Admission] < SELECTEDVALUE ( 'Table3'[Date for filtering] )
            )
        )
    RETURN
        IF (
            MAX ( 'Table2'[Date of Admission] ) <= _test,
            MAX ( 'Table2'[Date of Admission] ),
            BLANK ()
        )
    

     

    3. Create a measure to find the maximum RollNo.

    MaxRollNo = 
    VAR SelectedDate = MAX(Table3[Date for filtering])
    RETURN
    MAXX(
        FILTER(
            Table2,
            Table2[Date of Admission] < SelectedDate
        ),
        Table2[RollNo]
    )

     

    If your Current Period does not refer to this, please clarify in a follow-up reply.

     

    Best Regards,

    Clara Gong

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

    • aatish178's avatar
      aatish178
      Icon for Helper IV rankHelper IV

      Dear Clara,

      Thanks for your reply.

      However my final expectation is to show max of roll no. Along with admission date in the table visual. That means a single row consisting of above mentioned values., but the moment I am adding max roll no. Measure and admission date in table visual it is showing me blank dates for max roll no.

       

      Can you pls help how to fix this

      • aatish178's avatar
        aatish178
        Icon for Helper IV rankHelper IV

        here after selecting date for filtering., I am proparly getting filtered dates., now for this filtered result I only want to show singal highlighted row in table visual as shown below:

         

    • aatish178's avatar
      aatish178
      Icon for Helper IV rankHelper IV

      Dear Ashish,

       

      I will check this and get back to you 🙂 

    • aatish178's avatar
      aatish178
      Icon for Helper IV rankHelper IV

      Hi Ashish, the solution is working as expected., however once we get filtered dates in one table visual., is it possible to show only max roll no. and respective admission date along as a single row in another table visual.,

      The user dont want to see other roll nos for filtered dates., their expectation is to see single max roll no., along with its admission date.

       

      That means only highlighted value should be visible in table visual