Forum Discussion

xli629b's avatar
xli629b
Icon for Helper II rankHelper II
4 years ago
Solved

Obtain Power BI filename from external tools or Analysis Services

I would like to obtain the filename of the user's report when they click the button for my external tool in the ribbon.


According to the documentation, I can get the Analysis Services server address and database ID in the arguments to my external tool, and I was able to obtain those. The database ID is a UUID. I can use those arguments to connect to Analysis Services, which contains the data and internals of the dataset, but I was not able to find the filename in the system tables.

Is there a way of obtaining the filename somehow either directly or from Analysis Services?


  • lbendlin wrote:

    maybe ask dgosbell how he did it for DAX Studio?


    I don't actually get the filename in DAX Studio, What I get is the title of the main window in Power BI Desktop.

     

    What I do is to:

    • Iterate over all the running msmdsrv.exe processes and find the one listening on the same port that was provided in the external tool parameters.
    • Then I find the parent process and if it is pbidesktop.exe I then get the title of the main window. This gives me a string like "My Report - Power BI Desktop" and I then just trim off the " - Power BI Desktop" from the end

     

    I am not able to get the full path to the PBIX file, to the best of my knowledge that information is not available via standard windows APIs. I think the only way to do this is to write a kernel level driver which could interogate which file handles another process has open (from what I've read some of the sysinternals tools do this)

9 Replies

    • xli629b's avatar
      xli629b
      Icon for Helper II rankHelper II

      I was actually thinking of the case when the report hasn't been published yet, and I'm trying to get it locally from something launched by the External Tools toolbar.

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User

        What's your programming language?  I would go for Powershell, something like

         

        Get-Process -Name "PBIDesktop" -FileVersionInfo

         

        and then drill into the file name.

         

  • V-lianl-msft's avatar
    V-lianl-msft
    Icon for Community Support rankCommunity Support

    Hi xli629b ,


    If you just want to get the file name of pbix, please try lbendlin  method. As far as I know, external tools in ribbon do not have this feature.

    Power BI Desktop passes the name and port number of its internal data model engine instance to the tool, and the current model name(not the pbix name).

    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.