Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
Hello Experts,
I’m trying to replicate the desired output from a working Calculated column into a measure using switch. Although my per line items are getting the desired result, the totals are a little inconsistent.
Calculated Column
CC Age =
SWITCH(
TRUE(),
DIM_MRF[Quantity] = DIM_MRF[QuantityDelivered],
DATEDIFF(
RELATED( DIM_PO[Date].[Date] ),
DIM_MRF[DeliveryDate].[Date],
DAY
),
DIM_MRF[Quantity] <> DIM_MRF[QuantityDelivered],
DATEDIFF(
RELATED( DIM_PO[Date].[Date] ),
TODAY(),
DAY
)
)
Measure
M Age =
MAXX('DIM_MRF',
SWITCH(
TRUE(),
SELECTEDVALUE(DIM_MRF[Quantity]) = DIM_MRF[QuantityDelivered],
DATEDIFF(
RELATED(DIM_PO[Date].[Date]),
DIM_MRF[DeliveryDate].[Date],DAY
),
SELECTEDVALUE(DIM_MRF[Quantity]) <> DIM_MRF[QuantityDelivered],
DATEDIFF(
RELATED(DIM_PO[Date].[Date]),
TODAY(),DAY
)
)
)
| MRFNumber | PONumber | MaterialNumber | POItemNumber | Quantity | QuantityDelivered | POUnitPrice | DeliveryDate |
| IST-22-52 | PO-00001 | IST-00131 | 1 | 5 | 5 | 422 | 17/11/2022 |
| IST-22-52 | PO-00001 | IST-00135 | 5 | 5 | 12 | ||
| IST-22-52 | PO-00001 | IST-00136 | 6 | 2 | 3380 | ||
| IST-22-52 | PO-00001 | IST-00137 | 7 | 2 | 608 | ||
| IST-22-52 | PO-00001 | IST-00138 | 8 | 2 | 172 | ||
| IST-22-52 | PO-00001 | IST-00139 | 9 | 2 | 708 | ||
| IST-22-52 | PO-00001 | IST-00140 | 10 | 2 | 134 | ||
| IST-22-52 | PO-00001 | IST-00141 | 11 | 5 | 5 | 1146 | 17/11/2022 |
| IST-22-46 | PO-00002 | IST-00104 | 1 | 20 | 20 | 82 | 15/11/2022 |
| IST-22-46 | PO-00002 | IST-00102 | 3 | 10 | 10 | 556 | 15/11/2022 |
| IST-22-46 | PO-00002 | IST-00101 | 4 | 5 | 5 | 50 | 15/11/2022 |
| IST-22-46 | PO-00002 | IST-00100 | 5 | 1 | 1 | 740 | 15/11/2022 |
| IST-22-46 | PO-00002 | IST-00099 | 6 | 15 | 11 | 61.86 | 15/11/2022 |
| IST-22-46 | PO-00002 | IST-00098 | 7 | 2 | 2 | 1260 | 25/11/2022 |
| IST-22-46 | PO-00002 | IST-00094 | 11 | 5 | 5 | 9 | 15/11/2022 |
| IST-22-46 | PO-00002 | IST-00091 | 14 | 1 | 95.22 | ||
| IST-22-41 | PO-00003 | IST-00158 | 1 | 5 | 5 | 426.5 | 16/11/2023 |
| IST-22-41 | PO-00003 | IST-00159 | 2 | 4 | 4 | 358.26 | 16/11/2023 |
| IST-22-41 | PO-00003 | IST-00160 | 3 | 1 | 1 | 307.08 | 16/11/2023 |
| IST-22-41 | PO-00003 | IST-00161 | 4 | 4 | 4 | 196.19 | 16/11/2023 |
| IST-23-81 | PO-00004 | IST-2023-468 | 1 | 6 | 5385.61 | ||
| IST-23-81 | PO-00004 | IST-2023-467 | 2 | 6 | 1520 | ||
| IST-23-55 | PO-00005 | IST-2023-547 | 2 | 3 | 1265 | ||
| IST-23-55 | PO-00005 | IST-2023-548 | 3 | 6 | 255 | ||
| IST-23-55 | PO-00005 | IST-2023-549 | 4 | 6 | 255 | ||
| IST-23-55 | PO-00005 | IST-2023-550 | 5 | 3 | 198 | ||
| IST-23-55 | PO-00005 | IST-2023-553 | 8 | 2 | 1848.75 | ||
| IST-23-55 | PO-00005 | IST-2023-555 | 10 | 1 | 2985 | ||
| IST-23-55 | PO-00005 | IST-2023-546 | 1 | 3 | 5575 | ||
| IST-23-74 | PO-00006 | IST-00269 | 2 | 2 | 13.48 | ||
| IST-23-74 | PO-00006 | IST-00268 | 3 | 40 | 12.52 | ||
| IST-23-74 | PO-00006 | IST-00267 | 1 | 2 | 30 |
| Description | PONumber | Date | Currency | Vendor |
| Description 01 | PO-00001 | 16/08/2022 | USD | Vendor 1 |
| Description 02 | PO-00002 | 27/09/2022 | EUR | Vendor 2 |
| Description 03 | PO-00003 | 09/05/2023 | EUR | Vendor 2 |
| Description 04 | PO-00004 | 05/06/2023 | EUR | Vendor 2 |
| Description 05 | PO-00005 | 04/07/2023 | EUR | Vendor 2 |
| Description 06 | PO-00006 | 27/09/2022 | USD | Vendor 1 |
Solved! Go to Solution.
Remove the SELECTEDVALUE function from your measure. MAXX is already converting to row context so having SELECTEDVALUE in there is tripping it up.
Remove the SELECTEDVALUE function from your measure. MAXX is already converting to row context so having SELECTEDVALUE in there is tripping it up.
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 23 | |
| 23 | |
| 21 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 58 | |
| 54 | |
| 42 | |
| 30 | |
| 24 |