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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
kstiegler
Advocate I
Advocate I

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:

 

 

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

 

 

1 REPLY 1
lbendlin
Super User
Super User

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

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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