Skip to main content
Microsoft Idea

Power BI

New

Enable Organizational Authentication for Web URL Parameters for Excel Files on SharePoint

Vote (1) Share
Gregory Bell's profile image

Gregory Bell on 20 Mar 2022 15:14:59

Issue Definition:

  • I have a power query function that works in Power BI Desktop.
  • I want this function in a dataflow on the Service, but the dataflow is not authenticating SharePoint Excel URLs when it is based on a parameter input within my function.
  • I've followed the instructions from Refresh and dynamic data sources to keep the URL static, while passing the relative path as a "RelativePath" string. Unfortunately, this does not work for Excel files on SharePoint.
  • I still want to specify data privacy using my Organizational Account at the sharepoint.com level.

 

If-else logic can be used as an authentication workaround in the Service, detailed below. This is sufficient when the number of URLs is low, but not sufficient when when the number of URLs is high. The most ideal solution is just one line, also detailed below.


let Source = (Parameter1 as text) =>

   let

       Source = (if Parameter1 = "First URL String"

                   then Excel.Workbook(Web.Contents("First URL String"), null, true)

           else

           (if Parameter1 = "Second URL String"

                   then Excel.Workbook(Web.Contents("Second URL String"), null, true)

           else

           (if Parameter1 = "Third URL String"

                   then Excel.Workbook(Web.Contents("Third URL String"), null, true)

           else ""))),

       TableFromExcel = Source{[Item="Table1",Kind="Table"]}[Data]

 

/* 

URLs might look like:

"https://COMPANY.sharepoint.com/sites/SITE_NAME/Shared%20Documents/RELATIVE_PATH"

"https://COMPANY.sharepoint.com/sites/RELATIVE_PATH"


We cannot use this code in the Service, but it works on Desktop and is the most ideal solution:

       Source = Excel.Workbook(Web.Contents(Parameter1), null, true),

       TableFromExcel = Source{[Item="Table1",Kind="Table"]}[Data],

 */

 

 in TableFromExcel

in Source