Forum Discussion

rwaugh's avatar
rwaugh
Frequent Visitor
5 years ago
Solved

Date Slicers for Visuals

Hello,   Pretty new to Power BI so please excuse if this is a repeat question. I've tried searching for a solution for a couple of days now and am getting nowhere with the solutions I have found. B...
  • DataInsights's avatar
    5 years ago

    rwaugh,

     

    Try this solution (MM/DD/YYYY format).

     

    1. Create a date table SlicerDate that has no relationships.

     

    2. Create a date slicer using SlicerDate[Date].

     

    3. Create measure:

     

    Active Clients = 
    VAR vSlicerDate =
        SELECTEDVALUE ( SlicerDate[Date] )
    VAR vStartDate =
        MAX ( FactTable[Start Date (DD/MM/YYYY)] )
    VAR vEndDate =
        MAX ( FactTable[End Date (DD/MM/YYYY)] )
    VAR vEndDateAdj =
        IF ( ISBLANK ( vEndDate ), DATE ( 9999, 12, 31 ), vEndDate )
    VAR vResult =
        IF ( vSlicerDate >= vStartDate && vSlicerDate <= vEndDateAdj, 1 )
    RETURN
        vResult

     

    4. Create a filter in the visual using the measure [Active Clients]:

     

     

    5. Result:

     

    The concept is to use a disconnected date table, and control the filtering via DAX.

     

    As far as mockery, DAX makes a mockery of us all. 🙂