Provide username function in Power Query - M or DAX calculated columns
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.
Given that PowerBI is based on Analysis Services, could we ask for an implicit "Current User" dimension, perhaps with a single hierarchy "User Details", with two levels :
1: User Details (with a single member = the current user) and Attributes: User Name, User Principal Name, User Distinguished Name
2) Group Membership: (Multiple members, one per group the current user is a member of) and Attributes: Group Display Name, Group Distinguished Name
PowerBI Desktop must be able to "inject" this dimension into every workbook, as it has knowledge of the desktop user, and if the workstation is part of a domain , it can query and populate the Group memberships
PowerBI Services should also be able to create the equivalent, as it is AzureAD aware by definition.
So "package" this concept into PowerBI, and make it available to users.
To avoid having too much and also unnecessary data sent to clients
To avoid having too much and also unnecessary data sent to clients who own no privilege of having it and filtered with DAX RLS, or setting up thousands of login accounts in database engine to implement DATABASE RLS or using dmv to check login_name to filter rows, the only parameter-free way now is constructing SSAS solution which have built-in Role based row access control by setting up roles and adding domain groups/users in them. One core reason of the existence of this ability is the support of VBS in MDX, from which domain information can be accessed.
Yes for security reasons, the solutions for large user group reporting are limit.
So for database data source, either the DB team change the way Data Engine work to be like SSAS, or you power bi team adopt to the way Dataset in SSRS pagination report works.
I wonder how long you two are going to prolong with each other, it has been years so long.
Donal McCarthy commented
Does anyone know if this is even being considered?
Nice to get some acknowledgement of an idea with 340 votes...
ismael oltra commented
I found a way to implement this using a Bridge table. Here is the article on how to do it.
ismael oltra commented
I have been trying to do this in powerbi, and I tried all sort of tricks , without success, and it seems like powerbi does not allow to mask certain information depending on the user that is connecting to the report.
John Reilly commented
Customers don't understand why this is not possible as it is a very common desired use case.
It's insane that this feature isn't available... We've been trying to migrate from tableau to Powerbi, but without the ability to mask (NOT HIDE) data for GDPR compliance, we may need to go back
I too would need this feature, please.
With kind regards,
I would need it also.
We need to have this feature now. Why is this not in this tool yet?!?!
We would recommend this strongly as this would help the community to implement dynamic row level security. Without this, the solution requires us to go for one more layer or other complex solutions which is expensive.
We need this urgently for dynamic RLS!!!
Adam S commented
Just another reason why we are seriously starting to consider other BI tools. This is a basic feature that should have been available a long time ago.
Matt Urbanowski commented
We need this so we can still display the data (not filter out with RLS), but instead to customize what is displayed for the current user.
Adding this feature would really help to improve efficiency of queries and extend Power BI's usage. I don't understand why it is not already available.
i could also use an update on this feature, would be very usefull
Yash Gupta commented
Any update on this feature?