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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BI_Analyticz
Helper V
Helper V

Combine or Merge Columns if the Column Header contains "Type"

Hi I have a dataset like below. I can manually merge the columns to make it as one. Is it possible to write a condition to merge the columns.

 

Example: If the column header name contains Type then Merge all those columns to create a new column.

 

Col 1Col 2Col 3Type-123Type-456Col 8Col 10
       
       
       
       
1 ACCEPTED SOLUTION

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRS0lGCIBOfYBDp7O0CpCx9gIS/v79SbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Col 1" = _t, #"Type-000" = _t, #"Type-001" = _t, #"Type-123" = _t, #"Type-456" = _t, #"Col 8" = _t, #"Col 10" = _t]),
    #"Combined Columns" = Table.CombineColumns(Source, List.Select(Table.ColumnNames(Source), each Text.Contains(_, "Type")), each Text.Combine(List.RemoveItems(_, {null, ""}), "|"), "Combined")
in
    #"Combined Columns"

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

4 REPLIES 4
BI_Analyticz
Helper V
Helper V

@CNENFRNL Kindly help

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRS0lGCIBOfYBDp7O0CpCx9gIS/v79SbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Col 1" = _t, #"Type-000" = _t, #"Type-001" = _t, #"Type-123" = _t, #"Type-456" = _t, #"Col 8" = _t, #"Col 10" = _t]),
    #"Combined Columns" = Table.CombineColumns(Source, List.Select(Table.ColumnNames(Source), each Text.Contains(_, "Type")), each Text.Combine(List.RemoveItems(_, {null, ""}), "|"), "Combined")
in
    #"Combined Columns"

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRS0lHycQwDkiaGLiDSJxhEOnuDOJY+QMLf318pNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Col 1" = _t, #"Col 2" = _t, #"Col 3" = _t, #"Type-123" = _t, #"Type-456" = _t, #"Col 8" = _t, #"Col 10" = _t]),
    #"Combined Columns" = Table.CombineColumns(Source, List.Select(Table.ColumnNames(Source), each Text.Contains(_, "Type")), Combiner.CombineTextByDelimiter("|", QuoteStyle.Csv), "Combined")
in
    #"Combined Columns"

Screenshot 2021-06-01 160130.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

This is working but I am getting ||||4LS|4CKD since I have null for the previous columns (with Type headers). Can we add a condition to avoid null cells.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors