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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors