Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all,
I'm trying to get the total of one measure as the row value of another. This is to recreate Excel formulas from our finance dept.
In the example below, I need to 11,199,255 for all rows in TotalInvoiceAmt_PY. It works with my CY measure but not PY measures, probably because of the date filter I'm using. Can I get Power BI to refer to measure (not column) values?
TIA
InvoiceAmt_CY = sum('fact SalesInvoiceView'[SalesAmountTCY])
InvoiceAmt_PY = CALCULATE([InvoiceAmt_CY], SAMEPERIODLASTYEAR('dim DatePosted'[ActualDate]))
TotalInvoiceAmt_CY =
CALCULATE (
SUMX('fact SalesInvoiceView',[InvoiceAmt_CY]),
ALLSELECTED()
)
TotalInvoiceAmt_PY =
CALCULATE (
SUMX('fact SalesInvoiceView',[InvoiceAmt_PY]),
ALLSELECTED()
)
Solved! Go to Solution.
Your correct measures are:
TotalInvoiceAmt_CY =
CALCULATE (
[InvoiceAmt_CY],
ALLSELECTED()
)
TotalInvoiceAmt_PY =
CALCULATE (
[InvoiceAmt_PY],
ALLSELECTED()
)
Your measure returns BLANKs because... well, it's to do with the filter context and context transition. In a word, it's complex and it would take a lot of time and space to explain why you see what you see.
Advice is - you should never, ever do things like:
CALCULATE (
SUMX('fact SalesInvoiceView',[InvoiceAmt_PY]),
ALLSELECTED()
)
Summing over the entire (expanded) fact table with context transition because of a measure is a SURE WAY TO CALCULATE INCORECT NUMBERS. Please stay away from this practice. Please do not ever iterate over a fact table. This will not only be agonizingly slow. It's extremely dangerous for the correctness of the calculation.
Best
D
Your correct measures are:
TotalInvoiceAmt_CY =
CALCULATE (
[InvoiceAmt_CY],
ALLSELECTED()
)
TotalInvoiceAmt_PY =
CALCULATE (
[InvoiceAmt_PY],
ALLSELECTED()
)
Your measure returns BLANKs because... well, it's to do with the filter context and context transition. In a word, it's complex and it would take a lot of time and space to explain why you see what you see.
Advice is - you should never, ever do things like:
CALCULATE (
SUMX('fact SalesInvoiceView',[InvoiceAmt_PY]),
ALLSELECTED()
)
Summing over the entire (expanded) fact table with context transition because of a measure is a SURE WAY TO CALCULATE INCORECT NUMBERS. Please stay away from this practice. Please do not ever iterate over a fact table. This will not only be agonizingly slow. It's extremely dangerous for the correctness of the calculation.
Best
D
Thanks for your feedback... could you recommend the correct approach to this problem? I have tried with ADDCOLUMNS ( VALUES but still get the row context.
D, you certainly did. Much thanks!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |