cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nsbars Regular Visitor
Regular Visitor

How to group and pivot records exclude nulls

Hello

I have such table (a lot of records, it's just example):

screen1.jpg

 

I need to get in PBI such result:

screen2.jpg

 

Please help.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: How to group and pivot records exclude nulls

@nsbars 

 

Please check if this helps

See File attached as well for the steps

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYqVYHQgHiMwgHEMzEyDH0BwuCxFAVwBE5kqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), 
    let _t = ((type text) meta [Serialized.Text = true]) in type table [tickets_id = _t, Author = _t, Assighnee = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"tickets_id", Int64.Type}, {"Author", Int64.Type}, {"Assighnee", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"tickets_id"}, 
    {{"Author", each List.First(List.RemoveNulls([Author]))},
    {"Assighnee", each Text.Combine(List.RemoveNulls(List.Transform([Assighnee],each Text.From(_))),",") }}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows", "Assighnee", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Assighnee.1", "Assighnee.2"})
in
    #"Split Column by Delimiter"
Try my new Power BI game Cross the River

View solution in original post

2 REPLIES 2
Highlighted
Super User
Super User

Re: How to group and pivot records exclude nulls

@nsbars 

 

Please check if this helps

See File attached as well for the steps

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYqVYHQgHiMwgHEMzEyDH0BwuCxFAVwBE5kqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), 
    let _t = ((type text) meta [Serialized.Text = true]) in type table [tickets_id = _t, Author = _t, Assighnee = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"tickets_id", Int64.Type}, {"Author", Int64.Type}, {"Assighnee", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"tickets_id"}, 
    {{"Author", each List.First(List.RemoveNulls([Author]))},
    {"Assighnee", each Text.Combine(List.RemoveNulls(List.Transform([Assighnee],each Text.From(_))),",") }}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows", "Assighnee", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Assighnee.1", "Assighnee.2"})
in
    #"Split Column by Delimiter"
Try my new Power BI game Cross the River

View solution in original post

nsbars Regular Visitor
Regular Visitor

Re: How to group and pivot records exclude nulls

@Zubair_Muhammad 

It really works! Thank you!

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (4,495)