The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello Folks,
I am new to DAX query in Power BI and struggling to use SelectedValue - any other ways would do as well.
The requirement is to show the data as per the Current Logged In User - in my table, I have got the User Principal Name which I using as follows:
CurrentUserData =
VAR CurrentDataFilter = FILTER(TimeReport, TimeReport[UserPrincipalName] =USERPRINCIPALNAME())
RETURN
SWITCH(
TRUE(),
SELECTEDVALUE(TimeReport[UserPrincipalName] = CurrentDataFilter),
FALSE()
)
This is not working, hence need your help here.
Thanks!
UserPrincipalName | Name | Date | Function | P1 | P2 | P3 |
john@thestrawberry.com | John | 01-12-2021 | TID | 5 | 5 | 5 |
christina@thestrawberry.com | Christina | 02-12-2021 | KID | 5 | 10 | 20 |
sarah@thestrawberry.com | Sarah | 03-12-2021 | AD | 1 | 15 | 2 |
christina@thestrawberry.com | Christina | 05-12-2021 | TID | 5 | 5 | 15 |
john@thestrawberry.com | John | 03-12-2021 | TID | 8 | 8 | 1 |
Solved! Go to Solution.
Got the solution and credit goes to @miguelarce
https://community.powerbi.com/t5/Developer/RLS-vs-Filter-for-current-user/m-p/329584
Measure1
WhoIsWatching = USERPRINCIPALNAME()
(that is email style usernames, or you can use USERNAME() for windows style users)
Measure 2
FilterByViewer = IF(selectedvalue(table[email])=[WhoIsWatching],1,0)
Drag Measure 2 as a filter for visual, select advanced filtering and set it to
"Show items when value IS 1"
Got the solution and credit goes to @miguelarce
https://community.powerbi.com/t5/Developer/RLS-vs-Filter-for-current-user/m-p/329584
Measure1
WhoIsWatching = USERPRINCIPALNAME()
(that is email style usernames, or you can use USERNAME() for windows style users)
Measure 2
FilterByViewer = IF(selectedvalue(table[email])=[WhoIsWatching],1,0)
Drag Measure 2 as a filter for visual, select advanced filtering and set it to
"Show items when value IS 1"
Hi fmourtaza,
do you have a test pbix file to share? it doesnt seem to work for me.
Thanks
Almost there - I am now able to filter the data based on the Current Logged In user.
Next is I wanna show Multiple Columns in my Visual (see a line with Values) - in the below case I get only 1 value - I tried to return a complete row but it throws me the error "Multiple columns cannot be converted to a scalar value" - any other way to show multiple columns?
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
80 | |
66 | |
53 | |
52 |
User | Count |
---|---|
121 | |
117 | |
77 | |
64 | |
63 |