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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Clara
Advocate II
Advocate II

Extract category related to maximum of sum?

Hello guys!

Let's say I have this dataset (called Table1):

 

UnitItem Price 
ACameras $   370,40
ALaptops $3.200,00
ASmartphones $1.250,00
BCameras $   620,80
BLaptops $2.700,00
BSmartphones $1.240,00
CCameras $   290,00
CLaptops $2.300,00
CSmartphones $1.600,00
DCameras $            -  
DLaptops $            -  
DSmartphones $            -  

  


And I want to extract how much each unit is spending overall (considering all items). I've used a combination of MAXX and SUMMARIZE in a measure: 

 

VAR sumtable = SUMMARIZE(Table1;Table1[Unit];"Sum Prices";SUM(Table1[Price]))

 

Which would return this summarized table:

 

UnitSum Prices
A $       4.820,40
B $       4.560,80
C $       4.190,00
D $                  -  

 

And then


RETURN MAXX(sumtable;[Sum Prices])

 

Which would return the maximum expense $ 4,820.40.

 

But now I want to make another measure which would tell me which unit has spent that much in total (which would be Unit A). Any way I can achieve that??

And a follow up question: If I were to fetch which unit has spent the LEAST (ignoring units with zero expense, like Unit D), how would that go?

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Clara,

 

Please try this measure:

max unit =
VAR sumtable =
    SUMMARIZE ( data, data[Unit], "Sum Prices", SUM ( data[ Price ] ) )
RETURN
    CALCULATE (
        SELECTEDVALUE ( data[Unit] ),
        FILTER ( sumtable, [Sum Prices] = MAXX ( sumtable, [Sum Prices] ) )
    )

Min unit =
VAR sumtable =
    SUMMARIZE ( data, data[Unit], "Sum Prices"SUM ( data[ Price ] ) )
RETURN
    CALCULATE (
        SELECTEDVALUE ( data[Unit] ),
        FILTER ( sumtable, [Sum Prices] = MINX ( sumtable, [Sum Prices] ) )
    )

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Clara,

 

Please try this measure:

max unit =
VAR sumtable =
    SUMMARIZE ( data, data[Unit], "Sum Prices", SUM ( data[ Price ] ) )
RETURN
    CALCULATE (
        SELECTEDVALUE ( data[Unit] ),
        FILTER ( sumtable, [Sum Prices] = MAXX ( sumtable, [Sum Prices] ) )
    )

Min unit =
VAR sumtable =
    SUMMARIZE ( data, data[Unit], "Sum Prices"SUM ( data[ Price ] ) )
RETURN
    CALCULATE (
        SELECTEDVALUE ( data[Unit] ),
        FILTER ( sumtable, [Sum Prices] = MINX ( sumtable, [Sum Prices] ) )
    )

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.

Top Solution Authors
Top Kudoed Authors