Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Create columns based on multiple filters

Hi  I have 2 tables "Employees" and "Leave" having relations many to many based on EmpID  Employee EmpID Date Status   Leave  EmpID StartDate  EndDate I have to c...
  • v-chenwuz-msft's avatar
    4 years ago

    Hi Anonymous ,

     

    Is that you want create a column in Employee Table?

    If yes, please try this code to create a column:

    CHECK =
    VAR _if_in_enddate =
        CALCULATE(
            MAX( 'Leave'[EndDate] ),
            FILTER( 'Leave', [EmpID] = EARLIER( Employee[EmpID] ) )
        )
    VAR _if_in_startdate =
        CALCULATE(
            MIN( 'Leave'[StartDate ] ),
            FILTER( 'Leave', [EmpID] = EARLIER( Employee[EmpID] ) )
        )
    VAR _if_between =
        IF(
            AND( [Date] > _if_in_startdate, [Date] < _if_in_enddate ),
            "Between Startdate and Enddate",
            "Not Between"
        )
    RETURN
        IF( ISBLANK( _if_in_enddate ), "Not in Leave", _if_between )
    

    Result:

    If i misunderstood you, please share some data without sensitive data and expect result.

     

    Pbix in the end you can refer.

    Best Regards

    Community Support Team _ chenwu zhu

     

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