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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MohitPowerBI
Frequent Visitor

Filter an entire table based on What If Parameter and Logged In User Name

Hello,

 

I am trying to filter the data based on logged in user and a cutom filter(slicer) which I created using What If Parameter of type Whole Number. I used below DAX to convert Whole Number Parameter to a string type slicer ( for end users)

 

Projects = SWITCH(TRUE(), Projects[Projects Value] = 1, "My Projects Only", Projects[Projects Value] = 2, "All Projects")

Projects_WhatIf.png

Now, I want to use this slicer to filter the data from Project table. 

 

If User selects 'My Projects Only', It should display Projects where 'PROJECT_MANAGER = Logged in User' , otherwise it should display all rows.

 

Project Table.png

Any ideas on how to achieve this in Power BI/DAX are much appreciated!

 

Thanks,

Mohit

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Project Visible :=
var __selection = SELECTEDVALUE( Projects[Project Value] )
var __currentUser = USERNAME()
var __oneProjectVisible = HASONEVALUE( TheProjects[Project_ID] )
-- ManagerUserName must be in the format of __currentUser
var __currentProjManager = VALUES( TheProjects[ManagerUserName] )
return
	if( __oneProjectVisible,
			
		if(
			__selection = 1, -- my proj only
			__currentProjManager = __currentUser,
			TRUE() -- show all rows
		),
		
		-- don't show anything if many projects
		-- are visible in the current context.
		FALSE()
	)

-- The table with projects, TheProjects, must
-- have a column that stores your managers'
-- domain-name\user-name identifiers.
-- You can filter your table in a visual using
-- the above measure. If TRUE(), show the row,
-- if FALSE() hide.

Best

Darek

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Project Visible :=
var __selection = SELECTEDVALUE( Projects[Project Value] )
var __currentUser = USERNAME()
var __oneProjectVisible = HASONEVALUE( TheProjects[Project_ID] )
-- ManagerUserName must be in the format of __currentUser
var __currentProjManager = VALUES( TheProjects[ManagerUserName] )
return
	if( __oneProjectVisible,
			
		if(
			__selection = 1, -- my proj only
			__currentProjManager = __currentUser,
			TRUE() -- show all rows
		),
		
		-- don't show anything if many projects
		-- are visible in the current context.
		FALSE()
	)

-- The table with projects, TheProjects, must
-- have a column that stores your managers'
-- domain-name\user-name identifiers.
-- You can filter your table in a visual using
-- the above measure. If TRUE(), show the row,
-- if FALSE() hide.

Best

Darek

Thank you Darek, it worked like a charm 🙂

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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