The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 🙂
User | Count |
---|---|
26 | |
12 | |
8 | |
8 | |
5 |
User | Count |
---|---|
30 | |
15 | |
12 | |
12 | |
7 |