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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Passing username a parameter to Query

As of now we are loading all the Records from SQL Server and apply Row Level Security at PowerBI level to implement Data masking. We are seeing performance issues to load all the user Records . Can any one provide details of passing username as a parameter to SQL Query to fetch only the respective user Records. 

 

I understand that there is no option to pass Dax Function UserPrincipalname() / username() to SQL query from the Power Query editor. 

 

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , I doubt that is possible.

@ImkeF , is that possible?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @Anonymous ,
there is no native function to get the usernam in Power Query.
And using the SQL-Current_user function would only fetch the service account under which the dataset is refreshed.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Hi ImkeF, 

 

Yes you are correct . Even I have tried the SQL -CurrentUser() , this is returning the Service account which is configured for Data Refresh.

 

Not sure if any one had tried  "SQL Server Row Level Security". I am not sure whether this would work for this problem. 

https://docs.microsoft.com/en-us/sql/relational-databases/security/row-level-security?view=sql-serve...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.