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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Titatovenaar2
Advocate II
Advocate II

DAX: USERNAME() in measure to get rank from table specified to the user (.pbix included)

Hi guys,

 

I'm currently unable to show the top 2 'calls' (just a number in a table) specified to the User currently logged in, by using USERNAME(). With the current logic I came up with I receive the following error:

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

 

This is the result I want to achieve (also within included PBIX File).

The Green box is the result I want to achieve, but currently the Red box is where the error shows up when using USERNAME(), because in the example below uses the string "Irene" instead of USERNAME().

UserName = "Irene" --because with USERNAME() the other measures crash

Titatovenaar2_0-1624869755656.png

This is the DAX I use:

CallsPerUser_FilterMsr = 
CALCULATE( 
    SUM(CallsPerUser[CallsPerUser_Filter]), 
    FILTER(CallsPerUser, CallsPerUser[User] = [UserName])) 
CallsRank = 
RANKX(ALL(CallsPerUser),[CallsPerUser_FilterMsr],,DESC,Skip)
Calls Top 2 = CALCULATE([CallsPerUser_FilterMsr],FILTER(CallsPerUser,[CallsRank]<=2))

 

Also using visual level filter with Top N doesn't work with what I tried, because you'll get the reports with in general the highest Calls, instead of specified to the user.

Titatovenaar2_1-1624870444663.png

 

Any suggestions / workarounds?

PBIX File 

 

Kind regards,

Igor

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Titatovenaar2 , change this one and then try and visual level filter on CallsRank

 

CallsRank = 
RANKX(ALLselected(CallsPerUser[Report]),[CallsPerUser_FilterMsr],,DESC,Skip)

r

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Titatovenaar2 , change this one and then try and visual level filter on CallsRank

 

CallsRank = 
RANKX(ALLselected(CallsPerUser[Report]),[CallsPerUser_FilterMsr],,DESC,Skip)

r

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors