Forum Discussion

tssinha's avatar
tssinha
Regular Visitor
2 years ago
Solved

Dynamically Calculate a Measure based on Date Slicer Selection

I'm currently experiencing an issue I need help resolving.   I have two datasets representing a workforce, one with an active roster with start dates, and one with all of the people who've left and...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi tssinha ,
    Create two measures

    Total = 
    VAR ResignationDate =
    IF(
        SELECTEDVALUE(Resignations[Resignation Date]) = BLANK(),
        DATE(2024,12,31),
        SELECTEDVALUE(Resignations[Resignation Date])
    )
    RETURN
    CALCULATE(
        COUNT('Active Roster'[Name]),
        FILTER(
            'Active Roster',
            SELECTEDVALUE('Active Roster'[Start Date]) <= MIN('Date'[Date]) &&  ResignationDate >= MAX('Date'[Date])
        )
    )
    Result = 
    CALCULATE(
        COUNTROWS('Active Roster'),
        FILTER(
            'Active Roster',
            [Total] = 1
        )
    )

    Ensure there is a relationship between two table

    Final output

    Best regards,
    Albert He


    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly