Gym membership sign-ups
Sign-ups where the same person appears several times with differently typed emails. Keep the latest sign-up per member, deterministically.
intermediate · Skills: Normalising keys, Latest record per key, Remove duplicates on the right columns · Updated 2026-11-04
Data files
- signups.csv — SignupID, Email (case and spaces vary), SignedUpOn, Plan, Club.Download CSV (847 B)
Queries
Validated in the Power Query Exercises simulator against the files above. Paste them into Excel or Power BI yourself; the header comments explain each source binding.
Latest sign-up per member current-members.pq
Download .pqEmails normalised, then the row with the latest date kept per email. Returns 8 rows: Email, SignupID, SignedUpOn, Plan, Club.
// Latest sign-up per member
// Pack: Gym membership sign-ups (Power Query Exercises, https://powerqueryexercises.com/downloads/membership-signups-dedupe)
//
// Source bindings
// In the Power Query Exercises simulator each name below is bound directly to a pack file. In Excel or
// Power BI Desktop the first steps of this query do that binding instead:
// Signups the pack file signups.csv -> File.Contents(PackFolder & "signups.csv")
// Set PackFolder to the folder where you extracted the pack (keep the trailing backslash).
//
// Validated in the Power Query Exercises simulator (engine 0.1.0) against this pack's files; it returns
// 8 rows with columns Email, SignupID, SignedUpOn, Plan, Club.
// It has not been run in Excel or Power BI by us. This is query text, not a ready-to-refresh workbook.
// Independent practice material; not affiliated with or endorsed by Microsoft.
let
PackFolder = "C:\PQE\membership-signups-dedupe\",
Signups = File.Contents(PackFolder & "signups.csv"),
Source = Table.PromoteHeaders(Csv.Document(Signups, [Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.Csv]), [PromoteAllScalars=true]),
#"Clean email" = Table.TransformColumns(Source, {{"Email", each Text.Lower(Text.Trim(_)), type text}}),
#"Changed Type" = Table.TransformColumnTypes(#"Clean email", {{"SignedUpOn", type date}}, "en-US"),
#"Latest" = Table.Group(#"Changed Type", {"Email"}, {{"Row", each Table.Max(_, "SignedUpOn"), type record}}),
#"Expanded" = Table.ExpandRecordColumn(#"Latest", "Row", {"SignupID", "SignedUpOn", "Plan", "Club"})
in
#"Expanded"
Follow along in a host
Follow along in Excel
- Download the pack and extract the zip, for example to C:\PQE\<pack name>\.
- In Excel (Microsoft 365 or 2016+ on Windows), go to Data → Get Data → From Other Sources → Blank Query.
- In the Power Query Editor choose Home → Advanced Editor, select everything and paste the contents of the .pq file.
- Change the PackFolder line to the folder you extracted to, then choose Done.
- If Excel asks about privacy levels or file access, allow access to that folder. Then choose Home → Close & Load.
Follow along in Power BI Desktop
- Download the pack and extract the zip.
- In Power BI Desktop choose Home → Transform data to open the Power Query Editor, then Home → New Source → Blank Query.
- Choose Home → Advanced Editor, paste the contents of the .pq file and change the PackFolder line to your folder.
- Choose Done, check the preview against the expected rows in the query header, then Close & Apply.
Then try this
- Try Remove Duplicates on Email before cleaning it and compare the row counts.
- Add a newer sign-up for an existing member and refresh: their Plan changes to the new one.
Related lessons
Original fictional data, free to use for learning and teaching. Power Query Exercises is not affiliated with or endorsed by Microsoft.