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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello! Is there way to check current environment in Power Query?
I.e. - is it running on "desktop" or "service"?
The reason I'm asking - I want my report to automatically use different data sources, depending: is it working on my PC? or on the server?.
Solved! Go to Solution.
I've written a function that returns TRUE if Power BI Desktop is in use or FALSE if Power BI Service is used. It works very reliably for me, and I use it to select appropriate Parameters.
------------
// 250426 isDesktop Function
// This function returns True if the current environment is PBI Desktop, or False if it's running in Power BI Service
let
Source = () =>
let
// Get IP info from ipinfo.io
GetIPInfo = try Json.Document(Web.Contents("https://ipinfo.io/json")) otherwise null,
Org = if GetIPInfo <> null then Record.FieldOrDefault(GetIPInfo, "org", null) else null,
// It's Desktop if org is not Microsoft-hosted
isDesktop = Org <> null and not Text.Contains(Org, "Microsoft Corporation")
in
isDesktop
in
Source
I've written a function that returns TRUE if Power BI Desktop is in use or FALSE if Power BI Service is used. It works very reliably for me, and I use it to select appropriate Parameters.
------------
// 250426 isDesktop Function
// This function returns True if the current environment is PBI Desktop, or False if it's running in Power BI Service
let
Source = () =>
let
// Get IP info from ipinfo.io
GetIPInfo = try Json.Document(Web.Contents("https://ipinfo.io/json")) otherwise null,
Org = if GetIPInfo <> null then Record.FieldOrDefault(GetIPInfo, "org", null) else null,
// It's Desktop if org is not Microsoft-hosted
isDesktop = Org <> null and not Text.Contains(Org, "Microsoft Corporation")
in
isDesktop
in
Source
Brilliant, thank you!
My pleasure 🙂
hello pavel_severov, I have the same need, did you sort it out ?
I tried with parameters, but it's not satisfying:
- My M code uses env paramter to select right sources (if env = ...)
- My pbix has env = A
- I publish the pbix, it overwrites the PBI service parameter & triggers a refresh
- As soon as the refresh is finished, I can modify the PBI service parameter to env = B
I'm looking for a way without having to update PBI service parameter each time I publish.
Any idea ?
Alban
Hi aalev,
Unfortunately there is no way to get any environment data from Power BI scripts.
At least I don't know anything about it. I would be happy to be wrong.
Ok, thanks @pavel_severov , I submited a feature request here:
Please support with your votes !
Alban
ok
Best Regards
Maggie
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.