A working, editable copy of Lesson 1's pivot — built from raw grouping so you can see the machinery. This is yours to tinker with: change a number, add a fact, and re-run. The table re-pivots itself, because the table was never the data — the twelve facts are.

The lesson pivoted the cube with ToPivotGrid. Here the same result is hand-rolled in plain LINQ: one grouping primitive (Cell) turned into rows, a totals row, and a total column. Nothing is stored twice — every total is derived from the facts on each run.

Things to try: bump Equities 2025 from 340 to 500 and watch its row total and the 2025 column and the grand total all move together. Add a seventh position (new("Gold", "2024", 80) and new("Gold", "2025", 95)) and it appears as a new row with no other change. Add a "2023" fact — the totals still add up, though this two-column view only shows 2024/2025.

Hand-roll Lesson 1's pivot in plain LINQ: from the twelve asset facts, write a Cell(position, year) sum, derive the row list from the facts themselves, and render a DataGrid with 2024, 2025 and Total columns plus a TOTAL row — every number computed from the facts on each run.

You never told it what the table should look like — only which dimension goes on rows (Position) and which on columns (Year). Swap those two and the same facts become a different table. That separation — cube as the model, table as one view — is the whole of Lesson 1.


← Lesson 1 — Why model as a cube · Exercises

Reconnecting…
The connection to the server was interrupted. Trying to restore it…
Trying again…
The connection could not be restored. Reloading the page…
The server was updated. Reloading the page to pick up the latest version.