Forum Discussion

snaseem's avatar
snaseem
Helper I
2 years ago
Solved

Dynamically Date Range for Selected Values

Hi,

I want to display the data according to the selected values from Date Type, then accordingly the Date slicer filters the data in the table. If a user selects order date, then the date range selection should filter the table for order date.

 

Thanks,

  • In visual filter pane, filter Quantity so it doesn't show blank.

    Moving forward, it is a good practice to share a sample data (that can be copy pasted to enter data) that best represents your use case rather than a simplified one.

6 Replies

  • Hi snaseem ,

     

    For this, I'd create a disconnected dates table (no relationship to fact) and a measure that switches between order and shipping date based on a slicer selection. Sample measure

    Quantity = 
    SWITCH (
        SELECTEDVALUE ( DateType[DateType] ),
        "Order",
            CALCULATE (
                SUM ( 'Table'[Qty] ),
                FILTER ( 'Table', 'Table'[Order Date] IN VALUES ( Dates2[Date] ) )
            ),
        "Shipping",
            CALCULATE (
                SUM ( 'Table'[Qty] ),
                FILTER ( 'Table', 'Table'[Shipping Date] IN VALUES ( Dates2[Date] ) )
            )
    )
    

     

    Please see attached sample pbix

    • snaseem's avatar
      snaseem
      Helper I

      danextian  thanks, this worked. but I saw problem here. When I filter ship date from 1/06/2023 slicer, the ship date columns reflect date starting from 01/07/2023, I understand there is no data on this date, can it be fixed?

      • danextian's avatar
        danextian
        Super User

        Hi. What do you mean by there's no data? This screenshot shows that there is