March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I need to display login user name without using Row level Security,by automatically
Solved! Go to Solution.
Ah, okay, I'm with you now.
You would need to have a dimension table that contains all users' USERNAME or USERPRINCIPALNAME and this table would need to be related to all the other tables in your data model, maybe using Employee ID or similar.
You could then create a filter measure against this dimension table, something like this:
_userFilter =
VAR __currentUSER = USERNAME() // or USERPRINCIPALNAME()
RETURN
IF(
MAX(userDimension[userName]) = __currentUSER,
1,
0
)
Where you apply this measure to the visual-level filters and set it to __userFilter = 1.
Alternatively, you could write the same logic into each of your measures instead, something like this:
_filteredSales =
VAR __currentUSER = USERNAME() // or USERPRINCIPALNAME()
RETURN
CALCULATE(
SUM(salesTable[Sales]),
FILTER(
userDimension,
userDimension[userName] = __currentUser
)
)
Pete
Proud to be a Datanaut!
Hi @Mahamood0218 ,
You can use the USERNAME() or USERPRINCIPALNAME() functions in measures, literally just the function:
_userName = USERNAME()
_userPrincipleName = USERPRINCIPALNAME()
Pete
Proud to be a Datanaut!
Hi @BA_Pete ,
Actually i used userprincipalname() dax functioin after that generally we r going to creating the RLS there we are enter user mail id's but my requirement is without using Row level security need to display user login name
could you please suggest is there any logic
Hi @Mahamood0218 ,
I don't really understand what you mean by "without using Row Level Security". Both of the functions I gave you can be used independently in measures and placed in cards etc.
You can use either USERPRINCIPALNAME or USERNAME to get the user's login name, you just need to either extract text before '@' delimiter for USERPRINCIPALNAME, or after the domain name '/' for USERNAME.
If you want the person's actual forename/surname, then you would probably need to build a dimension table from your Active Directory records, something like this:
1) In PQ, connect to your Active Directory domain.
2) Find the User table and import it.
3) Find the [User] column that has nested records in it, expand, and select the [mail] column to expand.
4) Select [displayName] and [mail] and remove other columns.
You should now be able to use this as a dimension table and relate it to a calculated table that contains USERPRINCIPALNAME to translate it to a 'friendly' name.
Pete
Proud to be a Datanaut!
Hi ,
I have a case scenario :
One Customer application ,when user logs in and let's say he is a Staff he should see the report for staff ,if he is manager then he should see that for manager report .
I have created 3 reports one for Staff another for manager and so on all are in one workspace.
I have gone through the doc as mentioned and using Apps own data concept , i have completed all the steps till Step 8 ,but then when i am logged in to the application i can't see the report there..Is there anything else i need to do ?
What's next i have to do for interaction?
@BA_Pete my requirement is i have 10HR records in that records 5 records are availble in the name of Shaik and remaining 5 records are available in the name "Pete",then we ever i open the report in Power BI Service i will get only my records in the name of shaik ,after that when ever u open the same report at a time u will get only 5"Pete records" here my question is ,is there any logic to get particular records(along with our official mailid) by using userpricipalname()
when i login with my userid i need out like below
Ah, okay, I'm with you now.
You would need to have a dimension table that contains all users' USERNAME or USERPRINCIPALNAME and this table would need to be related to all the other tables in your data model, maybe using Employee ID or similar.
You could then create a filter measure against this dimension table, something like this:
_userFilter =
VAR __currentUSER = USERNAME() // or USERPRINCIPALNAME()
RETURN
IF(
MAX(userDimension[userName]) = __currentUSER,
1,
0
)
Where you apply this measure to the visual-level filters and set it to __userFilter = 1.
Alternatively, you could write the same logic into each of your measures instead, something like this:
_filteredSales =
VAR __currentUSER = USERNAME() // or USERPRINCIPALNAME()
RETURN
CALCULATE(
SUM(salesTable[Sales]),
FILTER(
userDimension,
userDimension[userName] = __currentUser
)
)
Pete
Proud to be a Datanaut!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
34 | |
30 | |
20 | |
19 | |
12 |