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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sum/summarize by 2 variables

Hi Team,

 

Appreciate you giving your expertise in the below, I have been trying for a while now 😞

 

I have opportunites, their value, and type. I want to sum by type for each unique opportunity ID.

 

For Ex: HW= 200 for opp A + 100 for opp C + 400 for opp D = 700

 

I use this 

Total Value= sumx(summarize(masterdata, masterdata[Opportunity ID], masterdata[Value] ), [Value])
 
But it doesnt give right graphs per type.
 
 
Opportunity IDValueType
A200HW
A200HW
A200HW
A200HW
B500SW
B500SW
C100HW
C100HW
D400HW
TTT700SW
DD300SW
DD300SW

 

Thanks,

Amr

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try:

Total Value = 
var _t=SUMMARIZE('masterdata',[Opportunity ID],[Value],[Type])
return SUMX(FILTER(_t,[Type]=MAX([Type])),[Value])

Eyelyn9_1-1637564689570.png

 

Best Regards,
Eyelyn Qin
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

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try:

Total Value = 
var _t=SUMMARIZE('masterdata',[Opportunity ID],[Value],[Type])
return SUMX(FILTER(_t,[Type]=MAX([Type])),[Value])

Eyelyn9_1-1637564689570.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@Anonymous Try:

Total Value= maxx(summarize(masterdata, masterdata[Type], "__Value", SUM(masterdata[Value]) ), [__Value])

That said, this is all about context. If you just place Type in a visual and use a simple SUM('masterdata'[Value]) then your numbers should come out correct according to Type.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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