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
Anonymous
Not applicable

Total By Last Records in a group

Good morning, 

 

I have a table that for each "Product Name" with a "Product Category" = 'Neuromodulator' I need to identify the MAX(fact inventory pk) and return the associated "Cumulative Stock" grouped by "Center Name". I have a measure that will return this correctly for each individual product in a center but now I want to just return the sum of all the records returned by center. 

 

lkhall_0-1710253011276.png

 

so in the case of the above image I now just want to return 1 record of 600. Below I have provided the measure that I am using to get the last record and its assoicated stock levels by Product Name. Any input would be greatly appreciated. 

 

Current On Hand = 

var _id = CALCULATE(
            MAX(FactInventory[fact inventory pk]),
            REMOVEFILTERS(FactInventory[Is Current Audit])
        )

return 

CALCULATE(
    SUM(FactInventory[Cumulative Stock]),
    FactInventory[fact inventory pk] = _id,
    REMOVEFILTERS(FactInventory[Is Current Audit])
)

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

 

Maybe you can use summarize() function to create a virtual tables in new measure and use the sumx() to get the sum.

Here for your reference:

vzhengdxumsft_0-1710296136281.pngvzhengdxumsft_1-1710296143620.png

Then add a new measure:

Measure 2 = 
	VAR _virtualtable = SUMMARIZE(
		ALLSELECTED('Table'),
		'Table'[Name],
		"Values", [Measure]
	)
	RETURN
		SUMX(
			_virtualtable,
			[Measure]
		)

The result is as follow:

vzhengdxumsft_2-1710296234665.png

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous 

 

Maybe you can use summarize() function to create a virtual tables in new measure and use the sumx() to get the sum.

Here for your reference:

vzhengdxumsft_0-1710296136281.pngvzhengdxumsft_1-1710296143620.png

Then add a new measure:

Measure 2 = 
	VAR _virtualtable = SUMMARIZE(
		ALLSELECTED('Table'),
		'Table'[Name],
		"Values", [Measure]
	)
	RETURN
		SUMX(
			_virtualtable,
			[Measure]
		)

The result is as follow:

vzhengdxumsft_2-1710296234665.png

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.