Forum Discussion

viswaaa's avatar
viswaaa
Helper IV
10 months ago
Solved

Single date picker with calender

Hi All,   I have a table where I have students' data. Here, I have two columns: join date and left date.   I need to create a date slicer that will control the visuals based on these dates. SO ...
  • Shubham_rai955's avatar
    Shubham_rai955
    10 months ago

    You do not need to create a relationship between the date table and your join/left date columns for this scenario to work in Power BI. Creating a relationship only on Join Date will filter the table directly, but you can use a measure-based approach for flexible filtering without relying on relationships to make your left date also work.

    Solution: Measure-Based Filtering Without Relationships

    • Create a calendar (date) table in your model and mark it as a Date Table.

    • Do NOT create a model relationship between your calendar table and your student table on Join Date or Left Date.

    • Create a DAX measure that, for each record, checks if the selected date from the slicer falls between Join Date and Left Date (or if Left Date is blank, treats as still active).

    • Use the single date picker slicer from the calendar table for user selection.

    • Apply this measure as a visual-level filter (= 1) on your table/visuals.

    Sample Measure:

     
    ActiveTillSelectedDate = VAR _selDate = SELECTEDVALUE('Calendar'[Date]) RETURN IF( 'StudentData'[Join Date] <= _selDate && (ISBLANK('StudentData'[Left Date]) || 'StudentData'[Left Date] >= _selDate), 1, 0 )

    Filter visuals with ActiveTillSelectedDate = 1.

    This way, selecting a date from the slicer will show all students who joined on or before that date and are either still active or left after that date, regardless of direct relationships in your data model.​