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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
rs3782
Frequent Visitor

Help formatting Data

I have the following data:

 

Monday, October 16, 2023 – Friday, October 20, 2023         
          
Ackerly, Lily          
Class/Enrollments Pay rate: Yoga Instructor          
Class DateClass TimeClass name# Clients# CompsBase PayAssistant PayBonus PayEarnings 
10/16/20234:30 pmRECOVER 505050
      50 50
   # Services# Clients# CompsBase Earnings Earnings 
Total for Ackerly, Lily 150$50.00  50 

 

I'd like to get it in the following format:

 

InstructorPay RateClass DateClass TimeClass name# Clients# CompsBase PayAssistant PayBonus PayEarnings
Ackerly, Lily Yoga Instructor10/16/20234:30 pmRECOVER 5050  50

 

Please help!

 

1 REPLY 1
BA_Pete
Super User
Super User

Hi @rs3782 ,

 

Try this example query. It probably won't handle scenarios more advanced than what you've provided as your example data, but it should give you an idea of what's possible:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lVHBTsMwDP0Vq+NY0bRjO+y2lSIhgYbGhISqHkwJU0SaTHGG1Nv+Ab5wX0K6ZoMiVMbBzrPzYj87eR7cavWMdQjz0uonbiAeh5CwZAi77TtcGdG5TFh7GYQB/GlFmJ/AOjCn5Ss30vW6EbI+/VkqkSjKlNFSVlxZgjuswaDlE3jUK4RrRdZsnH7zz6Jw6Yq4VBssRfUVKNwHA0ilaHq2WFfrBs2QeCPCwSmRIIvK+nim1YY8ztAooVZ0bBqzKB5HfrsXkyGDdeXQIkvnD9nC6xs5Y83ZuN324+hdom/fez70sQdwz82bKDn1T9bR/csYS21Rwotbd+dHPT3+NsPZiJ0z9lNkUBSf", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t, Column7 = _t, Column8 = _t, Column9 = _t, Column10 = _t]),
    addInstructor =
    Table.AddColumn(
        Source,
        "Instructor",
        each if [Column1] = "Class Date" then "Instructor"
        else Source[Column1]{2}),
    addPayRate =
    Table.AddColumn(
        addInstructor,
        "Pay Rate",
        each if [Column1] = "Class Date" then "Pay Rate"
        else Text.AfterDelimiter(Source[Column1]{3}, ": ")),
    addEarnings =
    Table.AddColumn(
        addPayRate,
        "Earnings",
        each if [Column1] = "Class Date" then "Earnings"
        else Source[Column10]{5}),
    filterUnusedRows = Table.SelectRows(addEarnings, each ([Column2] <> " ")),
    removeUnusedCols = Table.SelectColumns(filterUnusedRows,{"Instructor", "Pay Rate", "Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Earnings"}),
    promoteHeaders = Table.PromoteHeaders(removeUnusedCols, [PromoteAllScalars=true])
in
    promoteHeaders

 

Example output:

BA_Pete_0-1698076024346.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.