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
itchyeyeballs
Impactful Individual
Impactful Individual

SumX using max

Hi all, 

 

I'm having an issue with using SumX and can't figure out what I'm doing wrong (the 'X' functions always trip me up)

 

I'm trying to calculate the sum of the maximum values accross groups.

 

My formula is 

=if(HASONEVALUE(Table1[col2]),
	max(Table1[Value]),
	sumx(values(Table1[col2]),max(table1[value]))
)

The results look like

SumX.GIF

 

The third grand total is showing 30 rather than 16, it seems like my sumx is using 15 twice rather than 15 + 1. Any ideas where I'm going wrong?

 

Thanks 

 

 

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@itchyeyeballs

 

hi, just add a Calculate in Max.

 

Measure 2 =
IF (
    HASONEVALUE ( Table1[col2] ),
    MAX ( Table1[Value] ),
    SUMX ( VALUES ( Table1[Col2] ), CALCULATE ( MAX ( table1[value] ) ) )
)



Lima - Peru

View solution in original post

3 REPLIES 3
Vvelarde
Community Champion
Community Champion

@itchyeyeballs

 

hi, just add a Calculate in Max.

 

Measure 2 =
IF (
    HASONEVALUE ( Table1[col2] ),
    MAX ( Table1[Value] ),
    SUMX ( VALUES ( Table1[Col2] ), CALCULATE ( MAX ( table1[value] ) ) )
)



Lima - Peru

Perfect, thank you!

A side note:

You can also get rid of the HASONEVALUE test, since if Col2 has one value then SUMX will iterate over that one value anyway:

 

=
SUMX ( VALUES ( Table1[Col2] ), CALCULATE ( MAX ( table1[value] ) ) )

Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

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.