Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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)
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.
Any ideas on how to achieve this in Power BI/DAX are much appreciated!
Thanks,
Mohit
Solved! Go to Solution.
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
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 🙂
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
24 | |
20 | |
15 | |
13 |
User | Count |
---|---|
51 | |
46 | |
39 | |
19 | |
19 |