Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Repeating Un-ordered Source to Table

Hello,

 

I am trying to turn a source that repeats column headers but in a none consistent order into a table. (The mess of the list is due to the web source which I have no control over). But I am so far getting nowhere quickly. It always repeats in a consistent number of rows per ID if that helps...

 

Input Table:

 

IDNameValue
0079e79Average0.202
0079e79Score A0.846
0079e79Score B0.916
0079e79Score G0.985
0079e79Score D0.443
0079e79Score C0.738
0079e79Score E0.683
0079e79Score F0.495
0079e79Status0.476
002e377Average0.070
002e377Score A0.453
002e377Score B0.447
002e377Score G0.765
002e377Score D0.788
002e377Score C0.143
002e377Score E0.987
002e377Score F0.285
002e377Status0.236
0061dd2Status0.140
0061dd2Average0.654
0061dd2Score A0.412
0061dd2Score B0.647
0061dd2Score E0.186
0061dd2Score F0.633
0061dd2Score D0.774
0061dd2Score C0.928
0061dd2Score G0.985

 

Output Table:

 

IDAverageScore AScore BScore GScore CScore DScore EScore FStatus
0079e790.2020.8460.9160.9850.7380.4430.6830.4950.476
002e3770.0700.4530.4470.7650.1430.7880.9870.2850.236
0061dd20.6540.4120.6470.7740.1860.6330.9280.1400.985

 

Thank you for any help,

  • Hi,

    You can do this with Pivot option in query editor in power BI,

     

     

    Code,

    let
        Source = Excel.Workbook(File.Contents("C:\Users\Dilumd\OneDrive - Help Sheet.xlsx"), null, true),
        Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
        #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"ID", type text}, {"Name", type text}, {"Value", type number}}),
        #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Name]), "Name", "Value")
    in
        #"Pivoted Column"

2 Replies

  • dilumd's avatar
    dilumd
    Impactful Individual

    Hi,

    You can do this with Pivot option in query editor in power BI,

     

     

    Code,

    let
        Source = Excel.Workbook(File.Contents("C:\Users\Dilumd\OneDrive - Help Sheet.xlsx"), null, true),
        Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
        #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"ID", type text}, {"Name", type text}, {"Value", type number}}),
        #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Name]), "Name", "Value")
    in
        #"Pivoted Column"
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much. I had no idea it was that easy!