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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
nmcp22
New Member

How to capitalize the first letter in this situation

Hi guys,

 

I'm new using Power BI. I created a measure Username = username(), which returned that.

 

nmcp22_4-1658323225561.png

 

Then I changed the expression to return User: Name, but the name is lower case.

User = CONCATENATE("User: ",mid(USERNAME(),find("\",USERNAME())+1,LEN(USERNAME())))
 

nmcp22_7-1658323514926.png


I want the name first letter upper and the rest lower, as in the example below. How can I do it?

nmcp22_8-1658323697391.png

 

 

Thanks

 

1 ACCEPTED SOLUTION

Hi @nmcp22 
I tried with my USERENAME ( ) and seems to work just fine.

2.png1.png

View solution in original post

6 REPLIES 6
v-jianboli-msft
Community Support
Community Support

Hi @nmcp22 ,

 

According to your description, I modified your original DAX. Please try:

 

User =

var _name = mid ( USERNAME (), find ( "\" , USERNAME ())+ 1 ,LEN ( USERNAME ()))

var _U = UPPER(LEFT(_name,1))

var _L = LOWER(RIGHT(_name,LEN(_name)-1))

return CONCATENATE("User:",CONCATENATE(_U,_L))

 

Output:

vjianbolimsft_0-1658732792191.png

 

Best Regards,

Jianbo Li

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

tamerj1
Super User
Super User

@nmcp22 

Please share the code that ended up with

tamerj1
Super User
Super User

@nmcp22 
Here is a solution that works for one word user name https://www.dropbox.com/t/gG8TzH0N6tJJPJgA

1.png

Username = 
VAR CurrentUser = SELECTEDVALUE ( UserNames[USER] )
VAR String = SUBSTITUTE ( CurrentUser, "\", "|" )
VAR String1 = "User"
VAR String2 = PATHITEM ( String, 2 )
VAR Length = LEN ( String2 )
VAR T1 = GENERATESERIES ( 1, Length, 1 )
VAR T2 = 
    ADDCOLUMNS ( 
        T1, 
        "@Letter", 
        VAR Letter = MID ( String2, [Value], 1 )
        RETURN
            IF ( [Value] = 1, UPPER ( Letter ), Letter )
    )
RETURN
    String1 & "\" & CONCATENATEX ( T2, [@Letter] )
tamerj1
Super User
Super User

Hi @nmcp22 
The username is usually one word. Just to confirm because the solution could be different, is there any possibility to be one than one word?

Hi @tamerj1,

Thank you for replying and sharing the document.

 

Yes, the expression "= username()" just returns one name after "\" but in lower case (in my case). 

I am trying to transform this name into a Proper case.

I followed the steps you sent me, which still show lower case names, or I am missing some steps.

Hi @nmcp22 
I tried with my USERENAME ( ) and seems to work just fine.

2.png1.png

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.