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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
johnnyboy_175
Frequent Visitor

Transpose, distinct values based on filter?

Table Example.PNGI cannot figure out the solution in edit queries. Basically i want to model the table as seen to be a single distinct item for 'item code' and the keywords to take up multiple collumns against that distinct row.

 

ie: 10 would have columns containing 10, Location, A, Complete'

ie:10-01 would have columns 10-01, hose, connector,area.

 

and so on.

 

Please note that the first keyword is always the distinct value in the key words column.

 

Cheers JC

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

HI @johnnyboy_175 

 

Try this code in Query Editor/Power Query 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0gERsTpQtk9+cmJJZn4eQsQRwXTOzy3ISS1JhYroGhiCdYNoZJGM/GJUJcn5eXmpySX5RSiiiUWpiUqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Item Code" = _t, #"Key Word" = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Item Code"}, {{"groupRows", each _, type table [Item Code=text, Key Word=text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each [groupRows][Key Word]),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3", "Custom.4"})
in
    #"Split Column by Delimiter"

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

 

View solution in original post

1 REPLY 1
Mariusz
Community Champion
Community Champion

HI @johnnyboy_175 

 

Try this code in Query Editor/Power Query 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0gERsTpQtk9+cmJJZn4eQsQRwXTOzy3ISS1JhYroGhiCdYNoZJGM/GJUJcn5eXmpySX5RSiiiUWpiUqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Item Code" = _t, #"Key Word" = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Item Code"}, {{"groupRows", each _, type table [Item Code=text, Key Word=text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each [groupRows][Key Word]),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3", "Custom.4"})
in
    #"Split Column by Delimiter"

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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