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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Skitzy
New Member

Split Column function for time sheets

Hi Everyone, 

 

I am New to PowerBi. I have been tasked to create a dashboard for our staff timesheet information. All the info relating to projects and hours worked comes in 1 single cell in this format:

 

"[{"1":8,"2":8,"3":8,"4":8,"5":8,"Project":"MT-Admin","Total":"40.00","Title":"Solutions dev tasks","Category":"General"},{}]"

I want to know how to seperate the "Project", "Total", etc from this cell into seperate columns using the what i assume is correct to use, delimiter function. 

Any idea how to accomplish this? 

Thank you.

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Skitzy maybe read it as a json that's what it looks like. here is an example

 

start a blank query and click advanced editor and paste this code, and you can change it as per your need.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiq6OUTKMUbKy0IlRMoLSxlDaBEqbQumAovys1OQSIC9GyTdE1zElNzMvRgkoEZJfkpgDFjYx0DMwgIhlluSkgsWC83NKSzLz84oVUlLLFEoSi7OLwSqcE0tS0/OLKsGK3FPzUotAhtTqVNfGKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Json.Document([Column1])),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Expanded Custom1" = Table.ExpandRecordColumn(#"Expanded Custom", "Custom", {"1", "2", "3", "4", "5", "Project", "Total", "Title", "Category"}, {"1", "2", "3", "4", "5", "Project", "Total", "Title", "Category"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom1",{"Column1"}),
    #"Removed Blank Rows" = Table.SelectRows(#"Removed Columns", each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null})))
in
    #"Removed Blank Rows"

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

5 REPLIES 5

You are correct, it is JSON data I should have mentioned that earlier, I will read through what you sent and report my results.

parry2k
Super User
Super User

@Skitzy maybe read it as a json that's what it looks like. here is an example

 

start a blank query and click advanced editor and paste this code, and you can change it as per your need.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiq6OUTKMUbKy0IlRMoLSxlDaBEqbQumAovys1OQSIC9GyTdE1zElNzMvRgkoEZJfkpgDFjYx0DMwgIhlluSkgsWC83NKSzLz84oVUlLLFEoSi7OLwSqcE0tS0/OLKsGK3FPzUotAhtTqVNfGKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Json.Document([Column1])),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Expanded Custom1" = Table.ExpandRecordColumn(#"Expanded Custom", "Custom", {"1", "2", "3", "4", "5", "Project", "Total", "Title", "Category"}, {"1", "2", "3", "4", "5", "Project", "Total", "Title", "Category"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom1",{"Column1"}),
    #"Removed Blank Rows" = Table.SelectRows(#"Removed Columns", each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null})))
in
    #"Removed Blank Rows"

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

Hi again,

I want to include all the original data from the timesheet too, the code you sent me has removed all other columns of info such as the staff name etc. is there another advanced editor code to keep this data and just seperate the things i mentioned within the JSon cell?

@parry2k 

This is exactly what i needed!

I will have to add other staff members to what you sent me and also other fields but this is perfect. I will have to learn this for myself.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.