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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
degranadost
Frequent Visitor

DAX function to upper the first letter of each word of a text

I have a column with a text, some of them are split by an space, others by a "-" and other by a "_". I want those text to have the first letter of a word as a capital letter.

 

For example:

I have this word, "walk-on", so as a result of the dax fucntion I want this "Walk-On"

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @degranadost - create a calculated column:

CapitalizedText =
VAR OriginalText = [Text]
VAR Length = LEN(OriginalText)
VAR Result =
    CONCATENATEX(
        GENERATESERIES(1, Length),
        VAR CurrentChar = MID(OriginalText, [Value], 1)
        VAR PreviousChar = IF([Value] = 1, " ", MID(OriginalText, [Value] - 1, 1))
        RETURN IF(
            PreviousChar = " " || PreviousChar = "-" || PreviousChar = "_",
            UPPER(CurrentChar),
            CurrentChar
        ),
        ""
    )
RETURN Result

 

 

rajendraongole1_0-1721409689529.png

 

Hope it works

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

You should ideally do this in Power Query.  If you are OK with my suggestion, then share some sample data to work with and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
degranadost
Frequent Visitor

Thanks Rajen, I only needed to add the function LOWER because all the text was in capial letter. I have only one question, in your solution it says [Value], what is that?

 

Hi @degranadost -we can do it in power query editor,by duplicating the column perform Capitalized transformation as below

Snapshot:

 

rajendraongole1_0-1721453280053.png

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





rajendraongole1
Super User
Super User

Hi @degranadost - create a calculated column:

CapitalizedText =
VAR OriginalText = [Text]
VAR Length = LEN(OriginalText)
VAR Result =
    CONCATENATEX(
        GENERATESERIES(1, Length),
        VAR CurrentChar = MID(OriginalText, [Value], 1)
        VAR PreviousChar = IF([Value] = 1, " ", MID(OriginalText, [Value] - 1, 1))
        RETURN IF(
            PreviousChar = " " || PreviousChar = "-" || PreviousChar = "_",
            UPPER(CurrentChar),
            CurrentChar
        ),
        ""
    )
RETURN Result

 

 

rajendraongole1_0-1721409689529.png

 

Hope it works

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi Rajen: In my case all the letter are with capital letter, is like this. Sorry, I have forgot to mention this so the result value is the same.

degranadost_0-1721420713266.png

 

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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