Case 5: RAG status and ranking

A wall of numbers does not work in the monthly meeting. Every cost center gets a RAG status, and the biggest overruns come first, so the time goes to the items that really matter.

In short: write a status with several levels as SWITCH(TRUE(), condition1, "Red", condition2, "Amber", "Green"), strictest condition first. RANKX(ALL(CostCenter[CostCenter]), [Variance]) returns a rank across all cost centers.

The situation

The June report from case 1, account type Expense. The company rule: more than 10% over budget is red and gets explained in the meeting, more than 5% is amber and gets watched, everything else is green, including any underspend.

Task 1: the RAG status

Task In the June report every cost center should get a RAG status: "Red" for more than 10% over budget, "Amber" for more than 5%, otherwise "Green". Create the measure "RAG Status".

Actual 535 rows, 5 columns
EntryIDDateCostCenterIDAccountIDAmount
123 Jan 2025300400088400
222 Jan 20253004000132600
312 Jan 2025200500036176
44 Jan 202560050005253.5
521 Jan 2025100600013276.2
630 Jan 202510060009613.8
716 Jan 2025200600049220
820 Jan 2025300600025440
929 Jan 2025400600012875
1029 Jan 2025500600017205
1110 Jan 202560060005045.04
1214 Jan 202560060004656.96

Showing the first 12 of 535 rows.

Measures: [Total Actual], [Variance %]

Budget 432 rows, 4 columns
DateCostCenterIDAccountIDAmount
1 Jan 20253004000221000
1 Jan 2025200500032300
1 Jan 202560050005530
1 Jan 2025100600021000
1 Jan 2025200600046000
1 Jan 2025300600024000
1 Jan 2025400600012500
1 Jan 2025500600015500
1 Jan 202560060009800
1 Jan 202510063004200
1 Jan 202520063007800
1 Jan 202560063003600

Showing the first 12 of 432 rows.

Measures: [Total Budget]

CostCenter 6 rows, 3 columns
CostCenterIDCostCenterDivision
100AdministrationAdministration
200ProductionOperations
300SalesSales
400MarketingSales
500ITAdministration
600WarehouseOperations
Account 7 rows, 4 columns
AccountIDAccountAccountTypeAccountGroup
4000RevenueIncomeRevenue
5000MaterialsExpenseMaterials
6000Salaries and WagesExpensePersonnel
6300RentExpenseOperating
6500TravelExpenseOperating
6800AdvertisingExpenseOperating
6900Other ExpensesExpenseOperating
Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

Showing the first 12 of 730 rows.

SWITCH with TRUE() checks the conditions in order, as in the lesson on IF and SWITCH. If the 5% limit came first, Sales with 10.9% would only be amber. In the report you then color the cells with conditional formatting by field value, or you use a KPI visual.

Task 2: the ranking

Task The meeting starts with the biggest overruns. Create the measure "Rank": the rank of each cost center by [Variance], with the biggest overrun ranked 1.

Actual 535 rows, 5 columns
EntryIDDateCostCenterIDAccountIDAmount
123 Jan 2025300400088400
222 Jan 20253004000132600
312 Jan 2025200500036176
44 Jan 202560050005253.5
521 Jan 2025100600013276.2
630 Jan 202510060009613.8
716 Jan 2025200600049220
820 Jan 2025300600025440
929 Jan 2025400600012875
1029 Jan 2025500600017205
1110 Jan 202560060005045.04
1214 Jan 202560060004656.96

Showing the first 12 of 535 rows.

Measures: [Total Actual], [Variance]

Budget 432 rows, 4 columns
DateCostCenterIDAccountIDAmount
1 Jan 20253004000221000
1 Jan 2025200500032300
1 Jan 202560050005530
1 Jan 2025100600021000
1 Jan 2025200600046000
1 Jan 2025300600024000
1 Jan 2025400600012500
1 Jan 2025500600015500
1 Jan 202560060009800
1 Jan 202510063004200
1 Jan 202520063007800
1 Jan 202560063003600

Showing the first 12 of 432 rows.

Measures: [Total Budget]

CostCenter 6 rows, 3 columns
CostCenterIDCostCenterDivision
100AdministrationAdministration
200ProductionOperations
300SalesSales
400MarketingSales
500ITAdministration
600WarehouseOperations
Account 7 rows, 4 columns
AccountIDAccountAccountTypeAccountGroup
4000RevenueIncomeRevenue
5000MaterialsExpenseMaterials
6000Salaries and WagesExpensePersonnel
6300RentExpenseOperating
6500TravelExpenseOperating
6800AdvertisingExpenseOperating
6900Other ExpensesExpenseOperating
Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

Showing the first 12 of 730 rows.

This exercise is part of Premium.

Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.

See Premium Already Premium? Log in

The first exercise in this lesson is free.

RANKX compares the value of the row with the value of every row of the table in its first argument. With ALL that is every cost center, whichever row is being calculated. More in the lesson on RANKX and TOPN.

Common mistakes

Conditions in the wrong order

SWITCH(TRUE(), [Variance %] > 0.05, "Amber", [Variance %] > 0.1, "Red", "Green") never shows red, because everything above 10% already matches the first condition.

Percentage as a whole number

[Variance %] > 10 is never true, because the measure returns 0.109, not 10.9. Write limits as decimals: 0.1.

RANKX without ALL

RANKX(CostCenter, [Variance]) only sees the one cost center of the row, and every row gets rank 1.

In real Power BI

  • Limits change: put them in a small table of their own or a parameter and refer to it in the measure instead of typing them into every formula.
  • In the total row RANKX shows rank 1, because all cost centers together compete with the single ones there. With IF(ISINSCOPE(CostCenter[CostCenter]), RANKX(…)) the total row stays empty.

Check your result

  • Task 1: Sales is red (10.9%), Production (8.9%) and IT (7.2%) are amber, Administration, Marketing and Warehouse are green. The total row at 6.3% is amber.
  • Task 2: Production ranks 1 at 8,293.70 over budget, then Sales, IT, Administration and Warehouse; Marketing, under budget, ranks 6.

Next: case 6, division report

Every division head sees only their costs, the title shows the division, and shares refer to all costs.

Go to case 6

Back to case 4 or the course overview.

Write to us

Choose language

Select your preferred language