Forum Discussion

Dieu's avatar
Dieu
Regular Visitor
2 years ago
Solved

Dynamic date time slicer

Hi everyone, 

 

I have 2 tables. The first table shows start time and end time of each lot number. Another table shows information in that time periods.

I want to create a slicer of lot number so that when I select lot number, I can see information in that time periods. I can't figure out how to do that.

Does anyone know how to do this please?

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, Dieu 

    ryan_mayu's solution is perfect. 

    And I would like to share some additional solutions below.

     

    According to your description, you want to create a slicer of lot number so that when you select lot number, you can see information in that time periods? 

     

    If I understand you correctly, then you can refer to my solution.  

     

    I have extended the dataset based on some of the data you provided: 

     

    Then you can New table: 
     

     

    CombinedTable = 
    VAR LotTable = 'Table1'
    VAR InfoTable = 'Table2'
    RETURN
        SELECTCOLUMNS (
            FILTER (
                CROSSJOIN ( LotTable, InfoTable ),
                Table2[Sample time] >= Table1[Intake Time Start]
                    && Table2[Sample time] <= Table1[Intake Time End]
            ),
            "Lot number", Table1[Lot Number],
            "Intake Time Start", Table1[Intake Time Start],
            "Intake Time End", Table1[Intake Time End],
            "Sample time", Table2[Sample Time],
            "Information", Table2[Information]
        )
    

     

    Finally add a Slicer and drag Lot Number into the field to filter it: 

     

     

    Here is the result: 

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Dieu 

    ryan_mayu's solution is perfect. 

    And I would like to share some additional solutions below.

     

    According to your description, you want to create a slicer of lot number so that when you select lot number, you can see information in that time periods? 

     

    If I understand you correctly, then you can refer to my solution.  

     

    I have extended the dataset based on some of the data you provided: 

     

    Then you can New table: 
     

     

    CombinedTable = 
    VAR LotTable = 'Table1'
    VAR InfoTable = 'Table2'
    RETURN
        SELECTCOLUMNS (
            FILTER (
                CROSSJOIN ( LotTable, InfoTable ),
                Table2[Sample time] >= Table1[Intake Time Start]
                    && Table2[Sample time] <= Table1[Intake Time End]
            ),
            "Lot number", Table1[Lot Number],
            "Intake Time Start", Table1[Intake Time Start],
            "Intake Time End", Table1[Intake Time End],
            "Sample time", Table2[Sample Time],
            "Information", Table2[Information]
        )
    

     

    Finally add a Slicer and drag Lot Number into the field to filter it: 

     

     

    Here is the result: 

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Dieu's avatar
      Dieu
      Regular Visitor

      Thank you a lot for your solution. It helps me a lot ! 

  • Dieu 

    you can create a measure

     

    Measure =
    VAR _start=max('Table'[Intake time start])
    VAR _end=max('Table'[Intake time end])
    return if (max('Table (2)'[Sample time])>=_start && max('Table (2)'[Sample time])<=_end,1,0)
     
    and add that measure to visual filter and set to 1
     
     
    pls see the attachment below