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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ChrisHedges
Frequent Visitor

Pivot Sales data to show true false if appearing in transaction

Hi, 

 

I currently have the below format of data:

ChrisHedges_0-1660701828388.png

 

I would like to get it to look like something like this:

ChrisHedges_2-1660701918578.png

I tried to pivot columns and it gave me this:

 

ChrisHedges_3-1660701985618.png

 

 

1 ACCEPTED SOLUTION
jbwtp
Memorable Member
Memorable Member

Hi @ChrisHedges,,

 

Something like this?

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLKz8hTitWJVjICcRKTs8EcYyAnILE0B84Jy0zOrkSoy1eKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [incremental_id = _t, name = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"incremental_id", Int64.Type}, {"name", type text}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "incremental_id", "incremental_id - Copy"),
    #"Pivoted Column" = Table.Pivot(#"Duplicated Column", List.Distinct(#"Duplicated Column"[name]), "name", "incremental_id - Copy", (x)=>List.ContainsAny(#"Duplicated Column"[#"incremental_id - Copy"], x))
in
    #"Pivoted Column"

 

Kind regards,

John

View solution in original post

1 REPLY 1
jbwtp
Memorable Member
Memorable Member

Hi @ChrisHedges,,

 

Something like this?

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLKz8hTitWJVjICcRKTs8EcYyAnILE0B84Jy0zOrkSoy1eKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [incremental_id = _t, name = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"incremental_id", Int64.Type}, {"name", type text}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "incremental_id", "incremental_id - Copy"),
    #"Pivoted Column" = Table.Pivot(#"Duplicated Column", List.Distinct(#"Duplicated Column"[name]), "name", "incremental_id - Copy", (x)=>List.ContainsAny(#"Duplicated Column"[#"incremental_id - Copy"], x))
in
    #"Pivoted Column"

 

Kind regards,

John

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors