Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Set query parameter automatically by logged in user?

Is it possible to have Power Query automatically set the value of a query parameter based on the user account logged into Power BI Desktop? We have a report which references an Excel file on our internal network. In order to refresh the data from that Excel file while editing the report in Power BI Desktop, the relative file path must be used, yet the query requires the absolute file path from Power BI Service. I've created a parameter called ViewingUser that sets the file path with an if statement, but I'm curious if it's possible to automatically populate the value of that parameter based on the user account logged into Power BI Desktop. Here is the relevant M code:



    FilePath = if ViewingUser = "Gateway" then "absoluteFilePath.xlsx" else "relativeFilePath.xlsx",
    Source = Excel.Workbook(File.Contents(FilePath), null, true),



Super User III
Super User III

A dataset refresh is independent of any "logged in" user (unless you use Direct Query which is not applicable in your scenario)


What you can do is import both sources into the dataset and then use RLS or other DAX rules to switch between them.


Note: Your file should reside on an internal file share, not on a PC drive. IE you should not have the absolute/relative path problem in the first place.

Helpful resources



We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!


The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors