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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
TonyRojas
New Member

Can USERPRINCIPALNAME be applied in Powquery so that a User only views the database that correspond?

Created 1 query to get the parameters of a user table called T_Usuarios. This user table T_Usuarios, has the columns: [IdUser], [Stage], [Server] and [NameDataBase]. How do you apply USERPRINCIPALNAME in Power Query, to be able to connect the user with the database that they should have access to?
Query to get parameters:

let

    // Usar la tabla importada desde Excel llamada T_Usuarios

    Usuarios = T_Usuarios,

    // Reemplazar por el nombre de usuario actual para pruebas locales

    CurrentUser = USERPRINCIPALNAME(), // Simulación para pruebas en Power BI Desktop

    UserRecord = Table.SelectRows(Usuarios, each [Name] = CurrentUser){0},

    varStage = UserRecord[Stage],

    varServer = UserRecord[Server],

    varDatabaseName = UserRecord[Nombre de la base de datos]

in

    [

        txtStage = varStage,

        txtServer = varServer,

        txtDatabaseName = varDatabaseName

    ]

1 ACCEPTED SOLUTION

No, USERPRINCIPALNAME() is a DAX function that is not available during the ETL (data load) process in Power Query.

 

If your data source is a SSAS type live connection then it is possible to pass credentials through.

View solution in original post

4 REPLIES 4
watkinnc
Super User
Super User

My solution works. 


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
watkinnc
Super User
Super User

I've set something up like this. First, you have to have A data model set up in order to use the userprincipalname function. So I just made a table with today's date that loaded to the date model. Then I added the userprincipalname function to the data model, and loaded the result to a page in Excel. I then used that cell with the user principal name as the source of a new query, which you can then use as a filter/parameter/whatever you like. It's important that you set that query to load upon opening the file, so that the current user's user principal name is ready when you refresh the rest of the data.

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
TonyRojas
New Member

I have created 1 query to obtain the parameters of a user table called T_Usuarios. This user table T_Usuarios, has the columns: [IdUser], [Stage], [Server] and [NameDataBase]. How do I apply USERPRINCIPALNAME in Power Query, in order to connect the user to the database that they should have access to? Query to get parameters:
let
// Use the imported table from Excel called T_Usuarios
Users = T_Usuarios,
// Replace with the current user name for local testing
CurrentUser = USERPRINCIPALNAME(), // Simulation for testing in Power BI Desktop
UserRecord = Table.SelectRows(Usuarios, each [Name] = CurrentUser){0},
varStage = UserRecord[Stage],
varServer = UserRecord[Server],
varDatabaseName = UserRecord[Database Name]
in
[
txtStage = varStage,
txtServer = varServer,
txtDatabaseName = varDatabaseName
]

No, USERPRINCIPALNAME() is a DAX function that is not available during the ETL (data load) process in Power Query.

 

If your data source is a SSAS type live connection then it is possible to pass credentials through.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.