Skip to main content

Power BI

Needs Votes

Provide username function in Power Query - M or DAX calculated columns

Vote (365) Share
's profile image

on 20 May 2016 01:15:53

Being restricted to just using username () in measures (or AllowedRowsExpression) means that you cannot use the context of the current user in slicers or page level or report level filters.

Just to be clear, the desired result is not data security (that can be done through roles), it is to provide relevance. We want to be able to show a page that shows (for example) My Teams timesheet hours, perhaps next to a report page that shows an overview of the entire company.

You can provide some neat filtering using measures containing username () , but in particular, you can’t provide slicers (or page filters) that are cut down to just the list of relevant items based on the user logged in.

It would be extremely helpful if you could access the username value either via a function in PowerQuery M, or to allow username () to be referenced in a calculated column using DAX.
Trying to use username () in a calculated column currently gives the error:

"CUSTOMDATA and USERNAME functions are not supported in calculated columns. These functions may only be used in Measures or in the AllowedRowsExpression."

Perhaps there are security, functional or performance reasons why this isn't possible, but thought it worth putting forward.

Comments (40)
's profile image Profile Picture

f6f7b669 f57c-4f43-8983-6201a5866ae0 on 05 Jul 2020 23:38:41

RE: Provide username function in Power Query - M or DAX calculated columns

i could also use an update on this feature, would be very usefull

's profile image Profile Picture

a7ebd1cd 7670-4d5f-b27b-6e3f8b6ed45c on 05 Jul 2020 23:37:52

RE: Provide username function in Power Query - M or DAX calculated columns

to use direct query and composite models effectively I need this feature to pass the user to the database

's profile image Profile Picture

0932b7ea 0693-44d1-b857-8d95f31d9a80 on 05 Jul 2020 23:35:48

RE: Provide username function in Power Query - M or DAX calculated columns

I urgently need this too!!! What is the status on this feature!

's profile image Profile Picture

abba35d1 1de5-4617-8c8b-c97ff098c557 on 05 Jul 2020 23:32:11

RE: Provide username function in Power Query - M or DAX calculated columns

Would be useful, otherwise I have to pass in this value as a parameter

's profile image Profile Picture

ac94c847 ef7b-4f10-8f39-d6f17c8b195c on 05 Jul 2020 23:32:05

RE: Provide username function in Power Query - M or DAX calculated columns

This idea should have way more votes and attention!

's profile image Profile Picture

e25bc9c8 d44a-4549-99be-4ce3b3dea04f on 05 Jul 2020 23:31:48

RE: Provide username function in Power Query - M or DAX calculated columns

Have there been any updates on this idea? As other have mentioned below, this is something that is severely needed on my end to get some good filters going. For example: allowing a manager to filter for their direct reports vs their entire organization. Using RLS allows me to give them access to their entire org, but I need to provide away for them to specifically filter for their direct reports.

's profile image Profile Picture

18fe93bf 9efa-4b99-9c9b-296c74a3dcf5 on 05 Jul 2020 23:23:12

RE: Provide username function in Power Query - M or DAX calculated columns

Brian is spot on. This restricts the ability to have different types of users seeing different views. As he says, it's possible with measures but slicers use only columns. Passing the username () in Embedded and presenting back a tailored dashboard to the user would be wonderful.
And it'll take Power BI to a new level of flexibility and development potential.

's profile image Profile Picture

051a94ff 3eea-4a19-a462-bdffd94c221c on 05 Jul 2020 23:22:24

RE: Provide username function in Power Query - M or DAX calculated columns

The ability to use the username in the column is critical for me as well. I need the ability to filter one visual to the current user, I can't use RLS because I am not trying to restrict the data but filter a visual.

's profile image Profile Picture

113e6165 cb73-475c-8ee5-bf80660cef3a on 05 Jul 2020 23:17:41

RE: Provide username function in Power Query - M or DAX calculated columns

Team, we are stuck on username () , we cannot use it in Report level or Page level until it is in calculated columns, especially Power BI reporting Server. if the functionality is not available within a month we are forced to move our reports to other reporting tools. Hope for a new update soon....

's profile image Profile Picture

980886e1 179e-416a-8f0d-26972de3844d on 05 Jul 2020 23:17:26

RE: Provide username function in Power Query - M or DAX calculated columns

Team, any updates for using current username in calculated column. This is a critical functionality in implementing Row level security dynamically.