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

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

Reply
jhammond
Frequent Visitor

Power Query use Modulo with varying number of rows

My end-game is to have one row per ClaimNo, with all the relevant information from the 3 or 4 rows combined into one.  I would use modulo, except the data can either be on 3 rows or 4 rows, so I'm not sure to handle that.  Any help or other ideas would be greatly appreciated.

 

jhammond_1-1668710716142.png

 

Combined Data SAMPLE for Forum 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @jhammond 

 

Here are my transformation steps. You can also download the pbix file attached at bottom to see details. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hVFdS8MwFP0roa9mbPls6ltREcHhUEFw7CFdgg2k7UiyQf+9t+pqZx+EC+fkknPuucl2mxW5ZFSoDGelMcHGCExxIdHzserRbXAnC53vKj9smwAJk1IOrR2eGty41OOXpJPF7+4AjTcbk9etwWj9gLgiSoxWm867fQ9ECjF32tRdO4x9SrUN10gQucgZoaP61YYGgC/JaklXlKIFOnM2d7trtPOAbZeQPgHXlf9dagh8HLZ+1IdozVmu8oJRLqdRCy4F539DEPozmUCK8UDnPv/fn9aldgxZ7hP8CLrvvLla26ayIdZfb30p3n0C", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ClaimNo = _t, Address = _t, #"City,State,Zip" = _t, Phone = _t, Email = _t, Agent = _t, Policy = _t, Term = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ClaimNo", Int64.Type}, {"Address", type text}, {"City,State,Zip", type text}, {"Phone", type text}, {"Email", type text}, {"Agent", type text}, {"Policy", type text}, {"Term", type text}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"ClaimNo", "Address", "City,State,Zip"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns",{{"Address", "Attribute"}, {"City,State,Zip", "Value"}}),
    Custom1 = Table.SelectColumns(#"Changed Type",{"ClaimNo", "Agent", "Policy"}),
    #"Renamed Columns1" = Table.RenameColumns(Custom1,{{"Agent", "Attribute"}, {"Policy", "Value"}}),
    #"Appended Query" = Table.Combine({#"Renamed Columns", #"Renamed Columns1"}),
    #"Removed Duplicates" = Table.Distinct(#"Appended Query"),
    #"Filtered Rows" = Table.SelectRows(#"Removed Duplicates", each [Attribute] <> null and [Attribute] <> ""),
    #"Pivoted Column" = Table.Pivot(#"Filtered Rows", List.Distinct(#"Filtered Rows"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @jhammond 

 

Here are my transformation steps. You can also download the pbix file attached at bottom to see details. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hVFdS8MwFP0roa9mbPls6ltREcHhUEFw7CFdgg2k7UiyQf+9t+pqZx+EC+fkknPuucl2mxW5ZFSoDGelMcHGCExxIdHzserRbXAnC53vKj9smwAJk1IOrR2eGty41OOXpJPF7+4AjTcbk9etwWj9gLgiSoxWm867fQ9ECjF32tRdO4x9SrUN10gQucgZoaP61YYGgC/JaklXlKIFOnM2d7trtPOAbZeQPgHXlf9dagh8HLZ+1IdozVmu8oJRLqdRCy4F539DEPozmUCK8UDnPv/fn9aldgxZ7hP8CLrvvLla26ayIdZfb30p3n0C", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ClaimNo = _t, Address = _t, #"City,State,Zip" = _t, Phone = _t, Email = _t, Agent = _t, Policy = _t, Term = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ClaimNo", Int64.Type}, {"Address", type text}, {"City,State,Zip", type text}, {"Phone", type text}, {"Email", type text}, {"Agent", type text}, {"Policy", type text}, {"Term", type text}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"ClaimNo", "Address", "City,State,Zip"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns",{{"Address", "Attribute"}, {"City,State,Zip", "Value"}}),
    Custom1 = Table.SelectColumns(#"Changed Type",{"ClaimNo", "Agent", "Policy"}),
    #"Renamed Columns1" = Table.RenameColumns(Custom1,{{"Agent", "Attribute"}, {"Policy", "Value"}}),
    #"Appended Query" = Table.Combine({#"Renamed Columns", #"Renamed Columns1"}),
    #"Removed Duplicates" = Table.Distinct(#"Appended Query"),
    #"Filtered Rows" = Table.SelectRows(#"Removed Duplicates", each [Attribute] <> null and [Attribute] <> ""),
    #"Pivoted Column" = Table.Pivot(#"Filtered Rows", List.Distinct(#"Filtered Rows"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Thank you so much!  This works perfectly.

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.

Top Kudoed Authors