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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
vnqt
Helper V
Helper V

SUM by categories of Max by categories

Hi,

 

I have 2 related tables : 

 Table 1 

GroupNom
BCRNom 1
BCRNom 2
BCRNom 3
CANom 4
CANom 5
CANom 6
CLSNom 7
CLSNom 8
CLSNom 9
COMNom 10
COMNom 11
TESNom 12
TESNom 13

 

Table 2 

NomUsedKEY
Nom 121KEY A
Nom 210KEY A
Nom 311KEY A
Nom 412KEY A
Nom 513KEY A
Nom 614KEY A
Nom 715KEY B
Nom 816KEY B
Nom 917KEY B
Nom 1018KEY C
Nom 1152KEY C
Nom 1236KEY C
Nom 1394KEY C

 

I would like to create the following matrix 

 

KEYGROUPUSED MAXTotal KEY
A  35 (21+14)
 BCR21 
 CA14 
B  17
 CLS17 
C  146 (52+94)
 COM52 
 TES94 
    

 

Thank you in advance

4 ACCEPTED SOLUTIONS
powerbidev123
Advocate III
Advocate III

Hi @vnqt , I believe only a measure for the total should be created. 

Total= Calculate(sum(table2[Key]),ALLEXCEPT(table2,table2[Key]))

View solution in original post

vojtechsima
Resident Rockstar
Resident Rockstar

Hello, @vnqt ,

 try this:

vojtechsima_0-1733415330321.png

max = 
var _max = MAX(table2[Used])
var _maxTotal = SUMX( VALUES('Table'[Group]), CALCULATE( MAX( table2[Used])))
var _result = IF( NOT ISINSCOPE('Table'[Group]), _maxTotal, _max)

return _result

View solution in original post

v-kongfanf-msft
Community Support
Community Support

Hi @vnqt ,

 

Agree with @vojtechsima solution, you can also try the following formula, which is also a good choice:

MaxUsedByGroup_ = 
VAR _max = MAX(Table2[Used])
VAR _maxTotal = SUMMARIZE(
    Table1,
    Table1[Group],
    "MaxUsed", CALCULATE(MAX(Table2[Used]))
)
VAR _result = IF(
    NOT ISINSCOPE(Table1[Group]),
    SUMX(_maxTotal, [MaxUsed]),
    _max
)
RETURN _result

vkongfanfmsft_0-1733450259102.png

 

Best Regards,
Adamk Kong

 

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

Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1733455453440.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
vnqt
Helper V
Helper V

Many thanks for your helps. I work all the solutions. 

Hi @vnqt ,

 

Thanks for your feedback.😀

 

Best regards,

Adamk Kong

Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1733455453440.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-kongfanf-msft
Community Support
Community Support

Hi @vnqt ,

 

Agree with @vojtechsima solution, you can also try the following formula, which is also a good choice:

MaxUsedByGroup_ = 
VAR _max = MAX(Table2[Used])
VAR _maxTotal = SUMMARIZE(
    Table1,
    Table1[Group],
    "MaxUsed", CALCULATE(MAX(Table2[Used]))
)
VAR _result = IF(
    NOT ISINSCOPE(Table1[Group]),
    SUMX(_maxTotal, [MaxUsed]),
    _max
)
RETURN _result

vkongfanfmsft_0-1733450259102.png

 

Best Regards,
Adamk Kong

 

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

vojtechsima
Resident Rockstar
Resident Rockstar

Hello, @vnqt ,

 try this:

vojtechsima_0-1733415330321.png

max = 
var _max = MAX(table2[Used])
var _maxTotal = SUMX( VALUES('Table'[Group]), CALCULATE( MAX( table2[Used])))
var _result = IF( NOT ISINSCOPE('Table'[Group]), _maxTotal, _max)

return _result
powerbidev123
Advocate III
Advocate III

Hi @vnqt , I believe only a measure for the total should be created. 

Total= Calculate(sum(table2[Key]),ALLEXCEPT(table2,table2[Key]))

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.