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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jflipse
Advocate III
Advocate III

Calculation error in a measure related to USERPRINCIPALNAME function

I am having issues with a calculation based on data originating from USERPRINCIPLENAME.  I created two measures, one to capture the user's info and the other to query a table that tells the type of the user.

 

Measure 1:

RLS User = USERPRINCIPALNAME()

 

Measure 2:

RLS RoleType =
// Get the role type for the RLS user from the ORG query
VAR _RLSUser = [RLS User]

RETURN

LOOKUPVALUE(
ORG[ROLETYPE],
ORG[SOFTWARE_UPDT_USR],
_RLSUser

)

 

Both measures were successful in their tasks, so I know the user's name and their role type, "Type1" and "Type2".

 

I then want to perform math in another meaure depending on the type returned.  If Type1 then I want to divide a number by 1, but if Type2 then I want to divide by 2.  Something like

 

Goal = 

VAR _Denominator = IF([RLS RoleType] = "Type1",1,2)

 

RETURN

Calculate (SUM(Revenue)/_Denominator,

'Product'[Product Name] = "Red"

)

 

But when I try this, I recieve the message that, "CUSTOMDATA, USERNAME, USERCULTURE and USERPRINCIPLENAME functions are not supported in calculated tables/columns.  These functions may only be used in Measures or in AllowedRowsExpression."  This is unexpected, since all my calculations are done within measures.

 

I have tried moving the determination of the denominator into it's own seperate measure thinking that perhaps having the calculation in a seperate measure from the IF logic would make a difference, but it did not.  I tried taking the value of the denominator and changing it to a string and then back to a number, but that resulted in the same error.

 

Any thoughts on how one might perform such a calulation without error?

 

Thanks!

2 REPLIES 2
amitchandak
Super User
Super User

@jflipse , seem like you are creating goal as column not meausre

Thanks @amitchandak , in my model I've confirmed I am creating Goal as a measure.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors