Forum Discussion

sebastianlauss's avatar
sebastianlauss
New Member
7 months ago
Solved

Filter Max Date Range with Single Select Slicer

Hey there!  I want to create a daily report that shows me historically accurate values ​​as they were at that time. In other words, if I select the date December 31, 2025 in the right-hand slicer, ...
  • srlabhe's avatar
    7 months ago
    To create a report that limits all data points to the maximum date selected in a slicer, you need to use a disconnected Date table for the slicer and a DAX measure to filter the report visuals. 
     
    Step-by-Step Guide
    1. Create a disconnected Date table for the Slicer
      • Go to the Modeling tab and select New Table.
      • Use DAX to create a new table for your slicer. This table should contain all possible dates you want to select. It should be independent (disconnected) from your main data table(s) to function correctly with the filtering measure.
      DAX
      Slicer Dates = VALUES('YourMainDataTable'[Date Column])
      • Make sure the relationship between this new Slicer Dates table and your main data table is inactive or non-existent.
    2. Create a Measure to Capture the Selected Date
      • In your main data table, create a new measure to capture the maximum selected date from your new Slicer Dates table.
      DAX
      Max Selected Date = MAX('Slicer Dates'[Date Column])
    3. Create a Filtering Measure
      • Create a second measure to use in your visuals' filter panes. This measure compares the date in the current visual's context with the Max Selected Date from the slicer.
      DAX
      Filter Measure = 
      VAR MaxDate = [Max Selected Date]
      VAR CurrentDate = MAX('YourMainDataTable'[Date Column])
      RETURN
      IF(CurrentDate <= MaxDate, 1, 0)
      • This measure returns 1 for any date in your main data table that is on or before the date selected in the slicer, and 0 otherwise.
    4. Apply the Filter Measure to Visuals
      • Add a Slicer visual to your report page, using the Date Column from the new Slicer Dates table (not your main data table).
      • For each visual in your report that needs to respect this filter (e.g., charts, tables), drag the Filter Measure into the "Filters on this visual" or "Filters on this page" pane.
      • Set the filter condition to show items when the value is is equal to 1. 
    Now, when you select a date from the Slicer Dates slicer, all visuals on the page/report will only display data from that date and all prior historical dates. The report will dynamically update to reflect the snapshot of data as it was at that specific point in time. 
  • cengizhanarslan's avatar
    7 months ago

    1) Create a dedicated As-Of Date table (disconnected)

    Do not use your main date table directly.

    AsOfDate =
    DISTINCT ( 'Date'[Date] )
    • No relationships

    • Used only in the single-select slicer (right side)

     

    2) Base all measures on the selected As-Of date

    _AsOfDate =
    SELECTEDVALUE ( AsOfDate[Date] )

     

    3) Then wrap every measure that should respect the snapshot with a <= filter.

    Sales As Of =
    VAR AsOf =
        SELECTEDVALUE ( AsOfDate[Date] )
    RETURN
    CALCULATE (
        [Sales],
        FILTER (
            ALL ( 'Date'[Date] ),
            'Date'[Date] <= AsOf
        )
    )

     

    4) Control the left slicer (date list) as well

    If the left slicer is also a date slicer, create a helper measure:

    Date Visible As Of =
    VAR AsOf =
        SELECTEDVALUE ( AsOfDate[Date] )
    RETURN
    IF (
        MAX ( 'Date'[Date] ) <= AsOf,
        1,
        0
    )

    Then:

    • Put this measure in the Filters on this visual

    • Filter to = 1