[Part 6] Scenario Planning the Finance Way [Fabric App]

At the end of this part your team plans in shared scenarios: approve a Base forecast, copy it, re-plan in the copy and compare both side by side.

Time: about 55 minutes (build 21 min, testing 18 min, two fix rounds 11 min).

Credits: not measured separately; part of the big Parts 4–6 block.

Finance teams rarely plan one number. They compare Base, Best and Worst cases, or forecast v1 against v2. And once a forecast is approved, it must not change silently. That is exactly the workflow we build here.


The rules, in plain words

I decided on these for the demo („everyone sees everything“; in a customer project you’d want roles, see Part 9):

Artikelinhalte

There is deliberately no way back from Final. An approved forecast stays as the reference; further planning happens in a copy. When I first thought „but what if I need to change Base?“, the answer was: that’s what scenarios are for.


Build it

You do:

6a. Commit first, so you can go back: Source Control (branch icon on the left) → message Forecast app working → Commit. If Source Control shows no changes, you’re already safe.

6b. Open the Copilot chat (Ctrl + Alt + I), click + for a new chat and check that Agent is selected below the input field.

Artikelinhalte

6c. Paste the prompt below and press Enter. Copilot first reads the documentation, then builds for about 20 minutes.

Artikelinhalte

6d. Copilot stops before deploying and explains the database and permission changes. Read them, then answer in the chat, for example Looks good, please deploy. When it asks to run commands, click Allow.

⚠️During the run, Copilot asks for permission several times (for example “Allow reading file outside of workspace?”). For reading files, running tests and building, you can safely choose Allow in this Session, so it doesn’t ask again. Take a closer look when the command deploys (npx rayfin up), deletes something, installs packages or pushes to GitHub (git push). Those deserve a click each. -> 🤔 If your not sure ask your AI companion what the permission means!

Prompt for your AI:

This is a Rayfin project (Microsoft Fabric Apps) from the Data App template. The sales forecast app works: actuals and Forecast Suggestion come from the salesModel semantic model via DAX, and forecasts are stored in the ForecastEntry entity. Read AGENTS.md, https://rayfin.ai/docs/reference/agent-rules.md, https://learn.microsoft.com/en-us/fabric/apps/data-models and https://learn.microsoft.com/en-us/fabric/apps/data-permissions first. Do not change the DAX queries or measures.

Add shared scenario planning for a team:
1. New entity "Scenario" (id, name, description optional, status Draft or Final, createdBy user_id, createdByName, createdAt).
2. ForecastEntry gets a scenarioId and an updatedBy field. The upsert key becomes scenario, region, product group and month. Existing entries move to a scenario named "Base".
3. Permissions: every signed-in user can read all scenarios and all forecast entries. Every signed-in user can edit forecast entries in Draft scenarios. Only the creator of a scenario can rename it, delete it or set it to Final. Replace the current per-user row policy on ForecastEntry accordingly.
4. A scenario selector in the header showing name, status and creator, plus "New scenario" with three start options: empty, from Forecast Suggestion, or copy of an existing scenario. Any scenario can be copied, including Final ones; preselect the most recently finalized scenario as source, and make sure the preselected source is stored even if it is the only option.
5. Scenarios with status Final are read-only for everyone; the creator can switch Draft to Final.
6. A compare view: pick two scenarios and show them side by side per region and product group, with the absolute and relative variance.
7. The chart shows the selected scenario; in the compare view both scenarios. The grid shows who last changed each value.

Before deploying, explain the database and permission changes and how existing data is migrated. Semantic model reads use the Fabric SDK route (SALES_MODEL_QUERY_SOURCE = "fabric-sdk"), which only works inside the Fabric portal, so do not rely on npm run dev for testing. After my confirmation, deploy everything with npx rayfin up, and confirm in your summary that the deployment ran. When you are done, end without further review loops.

This version already contains the two fixes I needed afterwards (copying Final scenarios, and the „only one option“ bug), so you get them on the first try.

Why the scenario is part of the upsert key: otherwise saving a value in „Best case“ would overwrite the same cell in Base.


Where the platform said no

Copilot stopped and asked how to handle „only Draft scenarios can be edited“. The reason is worth understanding: Rayfin’s row policies only see the record being written and the user’s claims. A rule like „this entry may only change if its scenario is Draft“ looks at another table, so the server can’t enforce it today. I answered:

Artikelinhalte

Copilot’s question. Its recommended option is to pause; for a demo, the answer below keeps it moving.

Do not pause. This is a demo, so proceed as follows:
1. Enforce on the server everything the documented Rayfin policies support: everyone can read all scenarios and entries; only the creator can rename, delete or finalize a scenario.
2. For the Draft-only write rule on ForecastEntry, first check whether a single-entity policy can enforce it, for example a locked flag on each ForecastEntry that is set when the scenario becomes Final, and checked on create and update. If that is supported and safe, use it.
3. If not, enforce the Final lock in the UI only, and add a clearly visible code comment and a README note: "Final lock is enforced in the UI only; server-side enforcement requires a separate path."
Explain which option you chose before deploying.

Copilot chose the UI-only lock and documented it. Fine for a demo, a must-fix for production. The same limitation is why a scenario can only be deleted while it is empty.

Stumbling block: Copilot’s question was so long that the answer options disappeared below the visible area, and I couldn’t scroll to them. Maximize the chat panel (square icon at its top right), then pick. Don’t press Ctrl + Enter blindly.

Artikelinhalte

Test it like a controller

Artikelinhalte

You do:

6e. Open the app from your workspace in the Fabric (https://app.powerbi.com/) portal (refresh with F5 if it was open). In the header you now see a scenario selector: Base should be there and hold your earlier values. The migration runs the first time a signed-in user opens the app, not during deployment.

⚠️It can take a minute till you see some data if you reloading it or loading it for the first time.

6f. Approve Base: with Base selected, plan a few values, click Save forecast, then click Set to Final. The inputs become read-only, and a note says the lock is UI-only.

Artikelinhalte
After Set to Final: the status says Final, and the app tells you honestly that the lock is UI-only.

6g. Copy it: click New scenario, choose Copy an existing scenario, pick Base as source, name it Forecast v2, click Create scenario. Check the selector: it must now show Forecast v2 before you edit anything.

Artikelinhalte
The New scenario form: name, Start from, the source scenario, then Create scenario.
Artikelinhalte
After creating: the selector already shows Forecast v2 · Draft. Only now start editing.

6h. Re-plan: change a few values in Forecast v2, click Save forecast. Switch the selector back to Base: Base is unchanged.

6i. Compare: open the Compare view, pick Base and Forecast v2. You see the absolute and relative variance per region and product group.

Artikelinhalte
The compare view after the fixes: real variances, zeros where nothing changed, no „-€0“.

Stumbling block: with only one scenario, „Copy an existing scenario“ did nothing. The dropdown showed Base, but selecting the only option fires no change event, so the app never stored it. My test values ended up in Base. Copilot’s own tests never covered „there is only one scenario“, which is every user’s day one. Test with the real starting state.

Artikelinhalte
Looks fine, but selecting the only option fires no change event, so the app never stored it.

The fix prompt I used (three issues in one, which is cheaper than three prompts):

New chat (+, Agent), paste, Allow, then refresh the app and repeat the test from 6e.

Three fixes, no changes to DAX, measures or permissions:
1. Bug: With only one scenario, "Copy an existing scenario" does nothing. The Copy scenario dropdown shows "Base · Draft", but the source is never stored in state because selecting the only option fires no change event. Initialize the source with the first available scenario or add a placeholder option "Select a scenario". After creating a scenario, switch to it. Add a test for the single-scenario case.
2. Compare view: label the period of the compared values in the header, e.g. "Oct–Dec 2026".
3. Rounding: compare whole-euro values on both sides, so tiny differences from unrounded suggestions do not show as "-€0" or "-0.0%". Treat differences below €0.50 as zero.
Deploy with npx rayfin up and confirm the deployment.

Checkpoint: plan → approve → copy → re-plan → compare works end to end, and the compare view shows real variances, no „-€0“.

One more observation for the next part: in the line chart, differences of 20–30 kEUR between scenarios disappear at almost 3 million per month. I needed a ruler. That’s why Part 8 is about IBCS, after we get our own hands on a chart in Part 7.

Artikelinhalte
The ruler problem: Base and Best case are 20–30 kEUR apart, but the lines lie on top of each other.

Commit point: Source Control → message Scenario fixes working → Commit.


Fabric Apps is in preview; menus and commands may change. Written October 2026. Co-authored with Claude as co-learner. Previous: Part 5 · Next: Part 7. #HumanAICoProgramming

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert