Skip to main content

Power BI

New

A PowerQuery (M) function that returns the name of currently executing query

Vote (26) Share
Raj Rao's profile image

Raj Rao on 31 Jan 2022 18:14:09

It would be awesome if one could retrieve the name of the current query using a M-function. If this were possible, then one could potentially duplicate queries, rename them and it would automatically load the data.


As an example:

  1. Loading an excel file using the name of the query (eg: Query is called MyDataFile. The name would be retrieved, concatenated into the path and a file named "myDataFile.xlsx" would be opened)
  2. Loading a CRM entity. The query would be named with its entity: Account, Contact, etc. The code would automatically pull the name and then load the right entity.


It would make life so much easier when we have to use the same data-source and retrieve different entities. Today, we duplicate the query, edit its code to point at the right file/entity/etc and move on. If such a function were available, we would duplicate the query, fix its name and voila, the data would be available.