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

Get certified as a Fabric Data Engineer: Check your eligibility for a 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700. Get started

Reply
ieatwater
New Member

How to concat multiple columns value by each row

Hi community,

 

I'm trying to concat col. A and col. B by each distinct value of each row (result = col. C).

How can I use power query or formula to do this, and capture new items in col. A and B automatically? i.e. if there is an A6, then col. C automatically populates A6B1, A6B2, A6B3...

 

Thanks in advance.

ieatwater_0-1717478089520.png

 

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @ieatwater,

 

Before

dufoq3_0-1717484000475.png

 

After

dufoq3_1-1717484011467.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lFyMlSK1QGyjUBsIwjbGMQ2hrBNQGwTCNsUxDZVio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    Combined = List.TransformMany(
        {0..List.Count(Source[Column1])-1},
        each Source[Column2],
        (x,y)=> Source[Column1]{x} & y
),
    ToTable = Table.FromList(Combined, (x)=> {x}, type table[Combined=text])
in
    ToTable

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

2 REPLIES 2
slorin
Super User
Super User

Hi @ieatwater 

 

With Excel

 

=TOCOL( Range_A & TRANSPOSE( Range_B ))
=TOCOL( A1:INDEX(A:A,COUNTA(A:A)) & TRANSPOSE( B1:INDEX(B:B,COUNTA(B:B)) ))
=TOCOL( Table1[Column1] & TRANSPOSE( Table2[Column2] ))

 

Stéphane

dufoq3
Super User
Super User

Hi @ieatwater,

 

Before

dufoq3_0-1717484000475.png

 

After

dufoq3_1-1717484011467.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lFyMlSK1QGyjUBsIwjbGMQ2hrBNQGwTCNsUxDZVio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    Combined = List.TransformMany(
        {0..List.Count(Source[Column1])-1},
        each Source[Column2],
        (x,y)=> Source[Column1]{x} & y
),
    ToTable = Table.FromList(Combined, (x)=> {x}, type table[Combined=text])
in
    ToTable

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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