Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
brewery_dba
New Member

Reference total of one measure in another

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

measure_total.png

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()

)

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

 

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

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

 

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. 

Anonymous
Not applicable

Have I not given you the correct measures at the top of my post?

Best
D

D, you certainly did. Much thanks!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.