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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
rs3782
Advocate I
Advocate I

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.