March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
I have to track attendance every month and would like to automate the process using power query. Every month I receive a list that has names and attendance. I want to merge the data and compress it so that the data doesn't stay in a long format.. See pictures in attachment so you have an idea what I mean. So far, I have managed to look like the left side. I want it to look like the right side. Thank you!
Solved! Go to Solution.
Here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFPSUQrOzSzJANKRQKwUqxOtFJKfC2SGZJTmJiELeyXmpQLZLvmpKKKohoClMFRDRGMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [FirstName = _t, LastName = _t, Day1 = _t, Day2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"FirstName", type text}, {"LastName", type text}, {"Day1", type text}, {"Day2", type text}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"FirstName", "LastName"}, "Attribute", "Value"),
#"Replaced Value" = Table.ReplaceValue(#"Unpivoted Other Columns","",null,Replacer.ReplaceValue,{"Attribute", "Value"}),
#"Filtered Rows" = Table.SelectRows(#"Replaced Value", each ([Value] = "Y")),
#"Pivoted Column" = Table.Pivot(#"Filtered Rows", List.Distinct(#"Filtered Rows"[Attribute]), "Attribute", "Value")
in
#"Pivoted Column"
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
NewStep=Table.Group(PreviousStep,{"First Name","Last Name"},List.Transform(List.Skip(Table.ColumnNames(PreviousStep),2),(x)=>{x,each Text.Combine(Table.Column(_,x))}))
Here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFPSUQrOzSzJANKRQKwUqxOtFJKfC2SGZJTmJiELeyXmpQLZLvmpKKKohoClMFRDRGMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [FirstName = _t, LastName = _t, Day1 = _t, Day2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"FirstName", type text}, {"LastName", type text}, {"Day1", type text}, {"Day2", type text}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"FirstName", "LastName"}, "Attribute", "Value"),
#"Replaced Value" = Table.ReplaceValue(#"Unpivoted Other Columns","",null,Replacer.ReplaceValue,{"Attribute", "Value"}),
#"Filtered Rows" = Table.SelectRows(#"Replaced Value", each ([Value] = "Y")),
#"Pivoted Column" = Table.Pivot(#"Filtered Rows", List.Distinct(#"Filtered Rows"[Attribute]), "Attribute", "Value")
in
#"Pivoted Column"
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
16 | |
13 | |
12 | |
9 |
User | Count |
---|---|
34 | |
31 | |
20 | |
19 | |
17 |