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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
sarava0483
Frequent Visitor

DAX for calculating Sum for aggregate value(based on MAx Date)

Hi , @GuyInACube 

 

Can anyone help me on this scenario , which i am struggling for 2 days to arrive the solution,

 

> Fact table with Date,Entity, App, Value

>Need to identify the Value for the Entity & App combination for maximum date

>This will dynamically aggragted based on the multiple date hierarchy filters (screenshot attached)

>In the grand total i should see the sum of individual aggration (by summarizing Entity, app, value from above (respective date hierarchy)

I have tried to get the 505 of the result using below measure, but finding challenges in the grand total.

Critical_Status2 =
VAR X=SUMX (
    GROUPBY (
        FILTER ( 'Sample', 'Sample'[Date] = MAX ( 'Sample'[Date] ) ),
        'Sample'[Entity],
        'Sample'[app],
        "CRT", SUMX ( CURRENTGROUP (), 'Sample'[Critical] )
    ),
    [CRT]
)
RETURN
if(HASONEVALUE('Sample'[Entity]),X,SUMX (ALLSELECTED('Sample'),X))
 
Agg.PNG

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @tomsmith213 ,

You can create another new measure as below and put this new measure to replace the original measure [Critical_Status2] onto the table visual. Later check if it can return the correct total values...

New Measure =
SUMX (
    GROUPBY ( 'Sample', 'Sample'[Entity], 'Sample'[app] ),
    SUMX (
        GROUPBY (
            'Calendar',
            'Calendar'[Year],
            'Calendar'[Quarter],
            'Calendar'[Month_Name]
        ),
        [Critical_Status2]
    )
)

yingyinr_1-1673405801369.png

 

In addition, you can refer the following links to try to solve your problem...

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

Dax for Power BI: Fixing Incorrect Measure Totals

 

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @sarava0483 ,

Whether your problem has been resolved? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards

Anonymous
Not applicable

Hi @tomsmith213 ,

You can create another new measure as below and put this new measure to replace the original measure [Critical_Status2] onto the table visual. Later check if it can return the correct total values...

New Measure =
SUMX (
    GROUPBY ( 'Sample', 'Sample'[Entity], 'Sample'[app] ),
    SUMX (
        GROUPBY (
            'Calendar',
            'Calendar'[Year],
            'Calendar'[Quarter],
            'Calendar'[Month_Name]
        ),
        [Critical_Status2]
    )
)

yingyinr_1-1673405801369.png

 

In addition, you can refer the following links to try to solve your problem...

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

Dax for Power BI: Fixing Incorrect Measure Totals

 

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Greg_Deckler
Super User
Super User

@sarava0483 First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
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.