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
varions
New Member

Transform merged tables with labels in data column

I have the following Table 1, which I receive in this format for multiple files, and would like to transform it into a more structured form (Table 2 below). Can anyone offer guidance on how to do so? Thanks!

Table 1

 FrequencyCost
Set A  
Peter70.15
Jane60.15
John30.2
Bob10.3
Total Set A170.05
Set B  
Mary20.25
Williams20.25
Kate60.15
Ken10.3
Richard30.2
Howard90.1
Total Set B230.05

 

Table 2

 FrequencyCostSet
Peter70.15Set A
Jane60.15Set A
John30.2Set A
Bob10.3Set A
Mary20.25Set B
Williams20.25Set B
Kate60.15Set B
Ken10.3Set B
Richard30.2Set B
Howard90.1Set B

 

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk4tUXBU0lECoVidaKWA1JLUIiDHHIgN9AxNwYJeiXmpQL4Zilh+Rh6QbwwWMwILOeUnAXmGYBFjsEhIfklijgLMDkOIoQYQA0CiTkg2+yYWVQLZRhADIWrCM3NyMhNzi9HFvRNLMBzknZqHZntQZnJGYlEKmis98sshgpYQ3WgOBTnJyBju0FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Frequency = _t, Cost = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Frequency", Int64.Type}, {"Cost", type number}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Set", each if [Frequency]=null and [Cost]=null then [Column1] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Set"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each not Text.StartsWith([Column1], "Set") and not Text.StartsWith([Column1], "Total"))
in
    #"Filtered Rows"

 

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk4tUXBU0lECoVidaKWA1JLUIiDHHIgN9AxNwYJeiXmpQL4Zilh+Rh6QbwwWMwILOeUnAXmGYBFjsEhIfklijgLMDkOIoQYQA0CiTkg2+yYWVQLZRhADIWrCM3NyMhNzi9HFvRNLMBzknZqHZntQZnJGYlEKmis98sshgpYQ3WgOBTnJyBju0FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Frequency = _t, Cost = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Frequency", Int64.Type}, {"Cost", type number}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Set", each if [Frequency]=null and [Cost]=null then [Column1] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Set"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each not Text.StartsWith([Column1], "Set") and not Text.StartsWith([Column1], "Total"))
in
    #"Filtered Rows"

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.