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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Hoping
Helper III
Helper III

SUMMARIZE over SUMMARIZECOLUMNS

I have a dataset as below:

 

Name  Year  OtherColumn  Points  
A2022S12
A2022S22
A2023S12.5
A2023S22.5
B2023S13
B2023S13

 

I have used SUMMARIZECOLUMNS to summarize by   Name and Year and calculated MAX(Points)  to get the below output:

 

Name  Year  Max Points  
A20222
A20232.5
B20233

 

 

VAR DistinctValueTable =

SUMMARIZECOLUMNS('MyTable'[Name], 'MyTable'[Year], "Max Points", MAX('MyTable'[Points]) )

 

I now need to SUM Max Points for each Name. How do I do this ?

 

SUMMARIZE(DistinctValueTable , [Name], SUM[Max Points])

 

is showing red sqiggly lines below Max Points. 

 

 

Any help is appreciated. @Sahir_Maharaj  @VahidDM @Greg_Deckler @Jihwan_Kim @lbendlin @ThxAlot @tharunkumarRTK 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

HI,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1726393099593.png

 

GROUPBY function (DAX) - DAX | Microsoft Learn

 

expected result table =
VAR DistinctValueTable =
    SUMMARIZECOLUMNS (
        'MyTable'[Name],
        'MyTable'[Year],
        "Max Points", MAX ( 'MyTable'[Points] )
    )
VAR ExpectedResultTable =
    GROUPBY (
        DistinctValueTable,
        MyTable[Name],
        "@expectedresult", SUMX ( CURRENTGROUP (), [Max Points] )
    )
RETURN
    ExpectedResultTable

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

HI,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1726393099593.png

 

GROUPBY function (DAX) - DAX | Microsoft Learn

 

expected result table =
VAR DistinctValueTable =
    SUMMARIZECOLUMNS (
        'MyTable'[Name],
        'MyTable'[Year],
        "Max Points", MAX ( 'MyTable'[Points] )
    )
VAR ExpectedResultTable =
    GROUPBY (
        DistinctValueTable,
        MyTable[Name],
        "@expectedresult", SUMX ( CURRENTGROUP (), [Max Points] )
    )
RETURN
    ExpectedResultTable

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
shafiz_p
Super User
Super User

Hi @Hoping Try this one :

DistinctValueTable = 

VAR x = SUMMARIZECOLUMNS(
    dataset1[Name],
    dataset1[Year],
    "Max Point", MAX(dataset1[Points])
)

VAR _result =
SUMMARIZE(
    x,
    [Name  ],
    "Total Points", SUMX(
        FILTER(x, [Name] = EARLIER([Name])),
        [Max Point]
    )
)

RETURN
_result

 

You can also use groupby over currentgroup.

 

 

Hope this helps!!

If, Please accept it as a solution!!


Best Regards,
Shahariar Hafiz

SachinNandanwar
Super User
Super User

VAR DistinctValueTable = 
    SUMMARIZECOLUMNS(
        'MyTable'[Name], 
        'MyTable'[Year], 
        "Max Points", MAX('MyTable'[Points])
    )

RETURN
GROUPBY(  
DistinctValueTable,
[Name],
"Max Points", SUMX(CURRENTGROUP(), [Max Points])  
)


Regards,
Sachin
Check out my Blog
lbendlin
Super User
Super User

SUMMARIZE(DistinctValueTable , [Name], "Sum by name", SUM([Max Points]))

Sahir_Maharaj
Super User
Super User

Hello @Hoping,

 

Can you please try the following approach:

VAR DistinctValueTable = 
    SUMMARIZECOLUMNS(
        'MyTable'[Name], 
        'MyTable'[Year], 
        "Max Points", MAX('MyTable'[Points])
    )

RETURN
SUMX(
    SUMMARIZE(
        DistinctValueTable,
        [Name],
        "Total Max Points", SUMX(DistinctValueTable, [Max Points])
    ),
    [Total Max Points]
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

@Sahir_Maharaj   Thank You. But I want a table and not a Measure. I tried SUMX but it is giving me incorrect results. SUMX is not summing for each Name I think instead the entire table. I get a large value repeated for each Name.

 

VAR DistinctValueTable =
SUMMARIZECOLUMNS(
'MyTable'[Name],
'MyTable'[Year],
"Max Points", MAX('MyTable'[Points])
)

// Giving incorrect results
VAR SumDistinctTable =
SUMMARIZE(
DistinctValueTable,
[Name],
"Sum of Distinct",
SUMX(DistinctValueTable, [Max Points])
)

EVALUATE (SumDistinctTable)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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