Forum Discussion

cjbaguley's avatar
cjbaguley
Helper I
10 months ago
Solved

Calculation Filter working when using Today Function, but not when I use a calculated date

Hey Folks,   I have a working measure that counts a number of users with a start date x number of days prior to today (<30,31 - 60, 61 - 90 etc). Works flawlessly for what I'm using it for, however...
  • OwenAuger's avatar
    OwenAuger
    10 months ago

    Hi again cjbaguley 

    Thanks for sharing the PBIX!

    I had a look and the measure itself actually seemed to be working correctly, however some visual interactions were disabled in the report page, which meant the card visual wasn't updating based on filters.

     

    Nonetheless, I would recommend these other adjustments which I've made in the attached PBIX:

    1. Added columns Offset Min and Offset Max to Lender Start Date Slicer:

    2. Rewrote Lender Period Count to make use of these columns:

    Lender Period Count = VAR SelectedDate = [Selected Date]
    VAR SingleFilter = HASONEFILTER ( 'Lender Start Date Slicer'[Days Since Start Date] )
    VAR OffsetMin = IF ( SingleFilter, SELECTEDVALUE ( 'Lender Start Date Slicer'[Offset Min] ), -365 )
    VAR OffsetMax = IF ( SingleFilter, SELECTEDVALUE ( 'Lender Start Date Slicer'[Offset Max] ), 0 )
    RETURN
        CALCULATE (
            COUNT ( 'Lender Details'[LenderEmpNoText] ),
            KEEPFILTERS (
                'Lender Details'[Lender Role Start Date] >= SelectedDate + OffsetMin
                    && 'Lender Details'[Lender Role Start Date] <= SelectedDate + OffsetMax
            )
        )
            + 0

    The measure will apply a filter according to the single date range selected. If there are multiple or no selections made, the default offset is [-365,0].

    3. I also added a visual-level filter to the table visual: Lender Period Count ≠ 0.

     

    This seems to work as intended. Is this what you're looking for?