Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pratk30
Advocate I
Advocate I

Error on using UserName() function in custom table

Hi Folks,

 

I am getting below error after using measure which stored USERNAME().

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

 

Measure

CurrentUser = USERNAME()

 

Custom table

LingeringDS = FILTER(AssignmentTimephasedDataSet, AssignmentTimephasedDataSet[ResourcesOwner.ResourceEmailAddress] = [CurrentUser])

 

I need to filter one table data with current logged in user's email id  in both Power BI desktop and Service.

RLS is one the option but not suited to my requirement.

 

Can anyone plase help me on this.

1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @pratk30,

 

As we can see from the error message, it isn't supported. What's your purpose? Maybe there are other approaches. For example, we can use a measure like this, then we can filter out these 0s in the Filters.

Measure =
CALCULATE (
    IF (
        MIN ( 'AssignmentTimephasedDataSet'[ResourcesOwner.ResourceEmailAddress] )
            = USERNAME (),
        1,
        0
    )
)

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @pratk30,

 

As we can see from the error message, it isn't supported. What's your purpose? Maybe there are other approaches. For example, we can use a measure like this, then we can filter out these 0s in the Filters.

Measure =
CALCULATE (
    IF (
        MIN ( 'AssignmentTimephasedDataSet'[ResourcesOwner.ResourceEmailAddress] )
            = USERNAME (),
        1,
        0
    )
)

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


@v-jiascu-msft wrote:

Hi @pratk30,

 

For example, we can use a measure like this, then we can filter out these 0s in the Filters.

Measure =
CALCULATE (
    IF (
        MIN ( 'AssignmentTimephasedDataSet'[ResourcesOwner.ResourceEmailAddress] )
            = USERNAME (),
        1,
        0
    )
)

Best Regards,

Dale


Fortunately, I got this to work for me, but I find it rather unintiutive...  My beginner DAX mind says the following should have been sufficient:

IsCurrentUser = 'AssignmentTimephasedDataSet'[ResourcesOwner.ResourceEmailAddress] = USERNAME()

Unfortunately, DAX does not seem very intuitive as far as I can tell.







@v-jiascu-msft 

I have a very similar situation and create the same measure. But when browsing the cube via SSMS, I get the error: 

The function MIN takes an argument that evaluates to numbers or dates and cannot work with values of type String.

So I'm switching to FIRSTNONBLANK.

 

But this creates a MEASURE, and I can't use that in a FILTER on a page.

Any advice is appreciated.




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





Hi @v-jiascu-msft,

 

It worked for me, but as per this solution i need to create this measure for every table where email id is and need current user. Right?

 

 

Regards,

Prateek Mangal

Hi Prateek,

 

I'm afraid so. 

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.