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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
MagikJukas
Resolver III
Resolver III

sum of a product

Hello,

I have a table containing:

  • list of materials
  • A column with values
  • dates

the same material has the same value.

 

I want to calculate the sum of values groupped by materials, in other words avoiding summing twice the same material.

On top of that, I would like to display this measure in a chart at a constant.

 

I wrote this formula, but it does not aggregate correctly when selecting multiple materials.

M1 = CALCULATE(SUMX(ALLSELECTED(Data[Material]),SUM(Data[Stock Target])/COUNT(Data[Material])),ALL(Data[Date])

 

thanks

 

1 ACCEPTED SOLUTION
MagikJukas
Resolver III
Resolver III

Got it!

 

SUMX(ALLSELECTED(Data[Material]),CALCULATE(sum(Data[Stock Target]),ALL(Data[Date]))/CALCULATE(COUNT(Data[Material]),ALL(Data[Date])))

View solution in original post

3 REPLIES 3
MagikJukas
Resolver III
Resolver III

Got it!

 

SUMX(ALLSELECTED(Data[Material]),CALCULATE(sum(Data[Stock Target]),ALL(Data[Date]))/CALCULATE(COUNT(Data[Material]),ALL(Data[Date])))
FreemanZ
Super User
Super User

hi @MagikJukas 

unable to follow, you mentioned:

"same material has the same value"

and 

"avoiding summing twice the same material"

 

so why bother sum at all? Could you explain your expectation further?

I want to group by material and then sum the total.

It is like counting and count distinct, I do not want to count more than once the same material.

 

Hopefully it is more clear now.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.