cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pratk30 Regular Visitor
Regular Visitor

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

Accepted Solutions
Community Support Team
Community Support Team

Re: Error on using UserName() function in custom table

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.
3 REPLIES 3
Community Support Team
Community Support Team

Re: Error on using UserName() function in custom table

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.
pratk30 Regular Visitor
Regular Visitor

Re: Error on using UserName() function in custom table

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

Highlighted
Community Support Team
Community Support Team

Re: Error on using UserName() function in custom table

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.