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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nelsonwhyu
Frequent Visitor

Concatenate Dynamic COlumn

Hi,

I am trying to create a new Column "Key" by concatenating every column with header starting with "Level ". However, number of Levels are dynamic and varies across my source files. 

Level 1Level 2Level 3Key 
ABCA__B__C
DEFD__E__F
AEFA__E__F

 

As I won't know in advanced how many Level columns are there, I have a function that detects them and store in a List variable called Level_List

My question is if there's a way to replace the hard-coded column names (highlighted in red) in the following formula by my variable Level_List?
= Table.AddColumn(  Source, "Key2", each Text.Combine(  {[Level 1],[Level 2], [Level 3]}, "__")  )

Doing this:  = Table.AddColumn(  Source, "Key2", each Text.Combine( Level_List , "__")  )
gives me  Level 1__Level 2__Level 3  for each row which contenate the columns headers as Text rather than the values stored within.

Thanks!

Nelson

1 ACCEPTED SOLUTION
artemus
Employee
Employee

= Table.AddColumn(Source, "Key2", each Text.Combine( List.Transform(Level_List, (col) => Record.Field(_, col)), "__")  )

View solution in original post

10 REPLIES 10

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors