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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.