Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Sumanth327
Frequent Visitor

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 table(User Tasks) to show the items only that are related to current logged in user lab.

As in the screenshot below. I am able to create a measure(using USERPRINCIPALNAME functions) called Current User Lab from the Contacts Table. This measure shows the Lab of the current logged in user.

Sumanth327_0-1717065539437.png

Sumanth327_3-1717066422741.png

 

I would like to show the items in the main table below(User Tasks) ONLY that are related to Current User Lab i.e., show only items which matches with any one of the TrimmedDeptTestResponsible OR TrimmedDeptProjLeader OR TrimmedDeptCreatedBy Screenshot below.

Sumanth327_2-1717066093233.png

 

 

@dk_dk @Anonymous @Ritaf1983 @amitchandak @Ashish_Mathur 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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:

vjunyantmsft_0-1717378070521.png

vjunyantmsft_1-1717378078898.png

vjunyantmsft_2-1717378090190.png


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.

View solution in original post

3 REPLIES 3
Sumanth327
Frequent Visitor

Hi @Anonymous , Thank you so much for the help. 
Can you help me with this additional condition also which I got to know today. i.e.,

If the Dept Code measure is equal to 2132 then no filterings has to be applied i.e., show all the items without conditions you have suggested above.
If the Dept Code measure is not equal to 2132 then all the logic you have suggested has to be applied.

Sumanth327_1-1717161510726.png

 




Anonymous
Not applicable

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:

vjunyantmsft_0-1717378070521.png

vjunyantmsft_1-1717378078898.png

vjunyantmsft_2-1717378090190.png


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.

Anonymous
Not applicable

Hi @Sumanth327 ,

You mentioned that you've managed to get Current User Lab via measure, so I'll use Slicer instead in my tests next. Here is my sample data:

vjunyantmsft_0-1717118852999.png

Use this DAX to create a measure:

 

Measure = 
VAR _Current_User_Lab = [Current User Lab]
RETURN
IF(
    MAX('Table'[TrimmedDeptCreatedBy]) = _Current_User_Lab || MAX('Table'[TrimmedDeptProjLeader]) = _Current_User_Lab || MAX('Table'[TrimmedDeptTestResponsible]) = _Current_User_Lab,
    1,
    0
)

 

Set up the filter as shown below:
Drag the measure to the position indicated by the arrow:

vjunyantmsft_1-1717118982707.png

Set the measure = 1 and Apply filter:

vjunyantmsft_2-1717119075039.png

The final output is as below:

vjunyantmsft_3-1717119100546.png
vjunyantmsft_4-1717119108361.png

vjunyantmsft_5-1717119121161.png


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.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.