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
LordAssalt00
Regular Visitor

Concatenate with Order

Hi everyone, i have a problem with DAX syntaxt.

I would like to concatenate 2 columns into a new column but with a specific order. Let's make an example.
Suppose that we have into table A the columns: Names, Ages

NamesAges
Lucas, Walter, Marius Uan, Alex23,25,45,44
Debora21

 

I would like to calculate a new column called "Names and Ages" like that:
Lucas(23), Walter(25), Marius Uan(45), Alex(44)
Debora(21)



Could someone help me?
Thanks a lot in advice ❤️

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@LordAssalt00 Try this:

Column = 
    VAR __NamesTable = SUBSTITUTE(SUBSTITUTE([Names], " ", ""),",", "|")
    VAR __AgesTable = SUBSTITUTE(SUBSTITUTE([Ages], " ", ""),",", "|")
    VAR __Length = PATHLENGTH(__NamesTable)
    VAR __Table = 
        ADDCOLUMNS(
            GENERATESERIES(1, __Length, 1),
            "__Text", PATHITEM( __NamesTable, [Value]) & "(" & PATHITEM( __AgesTable, 1) & ")"
        )
    VAR __Result = CONCATENATEX( __Table, [__Text], ", " )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@LordAssalt00 Try this:

Column = 
    VAR __NamesTable = SUBSTITUTE(SUBSTITUTE([Names], " ", ""),",", "|")
    VAR __AgesTable = SUBSTITUTE(SUBSTITUTE([Ages], " ", ""),",", "|")
    VAR __Length = PATHLENGTH(__NamesTable)
    VAR __Table = 
        ADDCOLUMNS(
            GENERATESERIES(1, __Length, 1),
            "__Text", PATHITEM( __NamesTable, [Value]) & "(" & PATHITEM( __AgesTable, 1) & ")"
        )
    VAR __Result = CONCATENATEX( __Table, [__Text], ", " )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.