Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

How to create Dynamic Date-Time Range

Hello All,   I have been struggling with the below query from last few days.   I am trying to create a dynamic Date and Time ranges selection as per the user needs.   In my table i have swipe i...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Seward12533 I tried a different and easy way to do this.

     

    1. Break relationship from date range table to 'May' table.

    2. Write a measure to check current selection from date range table and return tag.

    Is Range =
    VAR currDate =
        MAX ( May[Date-Time] )
    VAR _start =
        MAX ( DateRange[SelectedDate-Time] )
    VAR _end =
        MAX ( DateRange[NextDate] )
    RETURN
        IF ( currDate >= _start && currDate <= _end, "Y", "N" )

     

    3. Create table visual based on 'May' table, drag above measure to visual level filter to filter matched records.

     

     

    and then i have written measures to calculate the max and min times and the duration.

     

    Min = CALCULATE(
    	MIN('May'[Date-Time]),
    		ALLSELECTED(May)	
    )
    
    Max = CALCULATE(
    	MAX('May'[Date-Time]),
    		ALLSELECTED(May)	
    )

     

    It worked for me.