2

If I have an Excel workbook that is available online and this workbook contains a couple of spreadsheets and some Power Query M functions, is it possible to invoke these functions from another Workbook?

I know how to load the workbook with Excel.Workbook(Web.Contents("url")) but this only lists the available spreadsheets and tables, but not the available functions.

My workbook is publicly available and I want to access the functions without special authorization.

1 Answer 1

0

This is not supported. However, it is possible to store your M scripts in a text file and run them.

  1. Copy the contents of the query (from the Advanced Editor) into a file.
  2. Use this to access the contents of that file: = Text.FromBinary(File.Contents("path to your file")). Lets call this step Source.
  3. Use Expression.Evaluate(Source, #shared) to evaluate that query. Expression.Evaluate will interpret a text value as code. #shared contains the list of all queries, functions, and constants in your code; it does not contain your current query's steps, however.

If you are mixing this with other data sources then you may need to either set the privacy levels for each source or disable privacy levels entirely, which you can do through the Options dialog under the Privacy section. Keep in mind that using this technique on unknown files on the internet when privacy levels are disabled may result in your data being leaked or exfiltrated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.