Convert exam table in PowerQuery

gargamalebarbosa

Board Regular
Joined
Aug 4, 2022
Messages
118
Office Version
  1. 365
Platform
  1. Windows
Hi,
How can I convert my table in PowerQuery like below image ?



1681860007167.png
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
This was the best that I am able to do, since I'm not sure how dynamic you are needing this to be. So with the way this currently is, your score columns will be populated as text, rather than number.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Student", type text}, {"Lesson", type text}, {"Point", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Student", "Lesson"}, {{"Point", each Text.Combine([Point],"/"), type nullable text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows", "Point", Splitter.SplitTextByDelimiter("/", QuoteStyle.None))
in
    #"Split Column by Delimiter"
 
Upvote 0
Solution
Here is another PQ solution
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"Student"}, {{"Data", each _, type table [Student=text, Lesson=text, Point=number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Data],"Index",1,1)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Data"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Lesson", "Point", "Index"}, {"Lesson", "Point", "Index"}),
    #"Added Prefix" = Table.TransformColumns(#"Expanded Custom", {{"Index", each "Point " & Text.From(_, "en-US"), type text}}),
    #"Pivoted Column" = Table.Pivot(#"Added Prefix", List.Distinct(#"Added Prefix"[Index]), "Index", "Point")
in
    #"Pivoted Column"
 
Upvote 0
Here is another PQ solution
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"Student"}, {{"Data", each _, type table [Student=text, Lesson=text, Point=number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Data],"Index",1,1)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Data"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Lesson", "Point", "Index"}, {"Lesson", "Point", "Index"}),
    #"Added Prefix" = Table.TransformColumns(#"Expanded Custom", {{"Index", each "Point " & Text.From(_, "en-US"), type text}}),
    #"Pivoted Column" = Table.Pivot(#"Added Prefix", List.Distinct(#"Added Prefix"[Index]), "Index", "Point")
in
    #"Pivoted Column"
Thank you for your answer. But it did not work right for me. Maybe i did somethings wrong.
 
Upvote 0
But it did not work right for me. Maybe i did somethings wrong.

This statement does not help me to help you. Need for you to be mores specific for me to advise you
 
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,613
Members
452,661
Latest member
Nonhle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top