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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
sivas07
Frequent Visitor

Data in a column to be split into diff column's as per below sample data

 I am new in Power BI , have tried Pivoting & Unpivoting but was not able to acheive the required format as this is a large data which needs to be updated on a daily basis in the table ..

Need help to get the Data transformed so that the report can be done ..

Sample data.jpg

 

 

 

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @sivas07,

 

Result

dufoq3_0-1715607679756.png

 

v1 (Table.Group)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI00jUw1TUyMDIBcjzzUjITgXRAUX6KoVKsTrSSEbqS0GBHqAIjsAJjDAXeQMI5PyUVYoAJTjsSi0qMwUpM0ZW4pxblJuZVgsxJLC6B2GOGrsitKDEvORXh2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"S. no." = _t, Date = _t, Country = _t, Items = _t]),
    GroupedRows = Table.Group(Source, {"Items"}, {{"All", each Table.RenameColumns(_, {"Items", [Items]{0}?}), type table}}),
    CombinedAll = Table.Combine(GroupedRows[All]),
    SortedRows = Table.Sort(CombinedAll,{{"S. no.", Order.Ascending}})
in
    SortedRows

 

v2 (List.Accumulate)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI00jUw1TUyMDIBcjzzUjITgXRAUX6KoVKsTrSSEbqS0GBHqAIjsAJjDAXeQMI5PyUVYoAJTjsSi0qMwUpM0ZW4pxblJuZVgsxJLC6B2GOGrsitKDEvORXh2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"S. no." = _t, Date = _t, Country = _t, Items = _t]),
    ItemsList = List.Distinct(Source[Items]),
    Ad_ItemColumns = List.Accumulate(
        ItemsList,
        Source,
        (s,c)=> Table.AddColumn(s, c, each if [Items] = c then c else null, type text)
    )
in
    Ad_ItemColumns

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

1 REPLY 1
dufoq3
Super User
Super User

Hi @sivas07,

 

Result

dufoq3_0-1715607679756.png

 

v1 (Table.Group)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI00jUw1TUyMDIBcjzzUjITgXRAUX6KoVKsTrSSEbqS0GBHqAIjsAJjDAXeQMI5PyUVYoAJTjsSi0qMwUpM0ZW4pxblJuZVgsxJLC6B2GOGrsitKDEvORXh2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"S. no." = _t, Date = _t, Country = _t, Items = _t]),
    GroupedRows = Table.Group(Source, {"Items"}, {{"All", each Table.RenameColumns(_, {"Items", [Items]{0}?}), type table}}),
    CombinedAll = Table.Combine(GroupedRows[All]),
    SortedRows = Table.Sort(CombinedAll,{{"S. no.", Order.Ascending}})
in
    SortedRows

 

v2 (List.Accumulate)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI00jUw1TUyMDIBcjzzUjITgXRAUX6KoVKsTrSSEbqS0GBHqAIjsAJjDAXeQMI5PyUVYoAJTjsSi0qMwUpM0ZW4pxblJuZVgsxJLC6B2GOGrsitKDEvORXh2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"S. no." = _t, Date = _t, Country = _t, Items = _t]),
    ItemsList = List.Distinct(Source[Items]),
    Ad_ItemColumns = List.Accumulate(
        ItemsList,
        Source,
        (s,c)=> Table.AddColumn(s, c, each if [Items] = c then c else null, type text)
    )
in
    Ad_ItemColumns

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors