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
alevandenes
Helper IV
Helper IV

Split dataset into columns and rows

Hi,

i would like some help. i need to analyze in powerBI some machine data, that unfortunately are provided to me this way.

I would need to have the rows from SO# to finished time into columns and the rest as different rows. Do you know of a way to do this?

alevandenes_1-1708357103713.png

 

This is the structure i would like to have:

alevandenes_2-1708357749365.png

 

Thanks a lot for your help,

Alessandra

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @alevandenes,

 

Created a simple mock up table, that follows a similair structure.

m_dekorte_1-1708361114632.png

You can copy this into a new blank query, replacing everything that is there, with this code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc87DoNADIThq0RbUzCzT/qUuQGiWCQ6Su4vVkhGLkbp7N/N53UNv74f5wdhCt9+9TFsk0VapIvRYnQxWUwuZovZxWKxuFgtVhebxfbEsbnj612UF7MCA0oMKjKiMiMpNLJSo/xjo0p3k+5FuTkrN6HcpHIzKjfHj9sN", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, #"Column 2" = _t]),
    NoBlanks = Table.SelectRows(Source, each [Column 1] <> null and [Column 1] <> ""),
    SplitTable = Table.Split( NoBlanks, 8 ),
    Transform = List.Transform( SplitTable, each Table.PromoteHeaders( Table.Transpose(_))),
    Combine = Table.Combine( Transform )
in
    Combine

As you can see, I've broken it down into a base pattern, or several steps. Removing blank labels, Splitting the table, Transforming the nested tables and combining them. Here's the result.

m_dekorte_0-1708361072778.png

 

I hope this is helpful

View solution in original post

2 REPLIES 2
m_dekorte
Super User
Super User

Hi @alevandenes,

 

Created a simple mock up table, that follows a similair structure.

m_dekorte_1-1708361114632.png

You can copy this into a new blank query, replacing everything that is there, with this code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc87DoNADIThq0RbUzCzT/qUuQGiWCQ6Su4vVkhGLkbp7N/N53UNv74f5wdhCt9+9TFsk0VapIvRYnQxWUwuZovZxWKxuFgtVhebxfbEsbnj612UF7MCA0oMKjKiMiMpNLJSo/xjo0p3k+5FuTkrN6HcpHIzKjfHj9sN", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, #"Column 2" = _t]),
    NoBlanks = Table.SelectRows(Source, each [Column 1] <> null and [Column 1] <> ""),
    SplitTable = Table.Split( NoBlanks, 8 ),
    Transform = List.Transform( SplitTable, each Table.PromoteHeaders( Table.Transpose(_))),
    Combine = Table.Combine( Transform )
in
    Combine

As you can see, I've broken it down into a base pattern, or several steps. Removing blank labels, Splitting the table, Transforming the nested tables and combining them. Here's the result.

m_dekorte_0-1708361072778.png

 

I hope this is helpful

THANK YOU

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