Forum Discussion

Sumanth327's avatar
Sumanth327
Frequent Visitor
2 years ago
Solved

Filter table based on current user details

Hi, I am new to Power BI and trying to figure out how to do filtering based on one of the current user details. Can someone please help me with the code for this.   I am trying to filter the main...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Sumanth327 ,

    Sorry for being late! Back to work.
    Assuming you already have a measure dedicated to getting Dept Code, we can change DAX to:

    Measure = 
    VAR _Current_User_Lab = [Current User Lab]
    VAR _Current_Dept_Code = [Dept Code]
    RETURN
    IF(
        _Current_Dept_Code <> 2132,
        IF(
            MAX('Table'[TrimmedDeptCreatedBy]) = _Current_User_Lab || MAX('Table'[TrimmedDeptProjLeader]) = _Current_User_Lab || MAX('Table'[TrimmedDeptTestResponsible]) = _Current_User_Lab,
            1,
            0
        ),
        1
    )

    Here I am defaulting to 2132 as a numeric type, if you are using a text type, please change it to “2132”.
    The final output is as below:


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