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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
bedata1
Frequent Visitor

DAX Formula Sum of Highest Version

Hi everyone,

I need your help.

Initial situation:
Different versions of a document can exist with different total amounts. I would now like to receive the highest version of each document and read out the total amount.
I would then like to display these total amounts summed up per month in a bar chart.

 

My try:

Latest_Version = 
VAR MaxVersionPerDocument =
    SUMMARIZE(
        'Sales Line Archive',
        'Sales Line Archive'[Document No_],
        "MaxVersion",
        CALCULATE(
            MAX('Sales Line Archive'[Version No_])
        )
    )

RETURN
    SUMX(
        MaxVersionPerDocument,
        CALCULATE(
            SUM(Sales Line Archive'[Amount]),
            'Sales Line Archive'[Document No_] = EARLIER([Document No_]),
            'Sales Line Archive'[Version No_] = EARLIER([MaxVersion])
        )
    )

 

Problem:
I believe that the DAX Formula is not quite correct.
In the table it shows me the amount twice, but in the total it only shows one amount.
The assumption is that there are duplicate values in the bar chart.

bedata1_0-1714657234913.png

 

Does someone have an idea how to adjust the DAX Formula?

1 ACCEPTED SOLUTION

@bedata1 Well, I would think something like:

Latest_Version Total = 
  VAR __GT = SUMX( SUMMARIZE( 'Sales Line Archive', [Document No_], "__Value", [Latest_Version] ), [__Value] )
  VAR __Result = IF( HASONEVALUE( 'Sales Line Archive'[Document No_] ), [Latest_Version], __GT )
RETURN
  __Result


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
bedata1
Frequent Visitor

@Greg_Deckler @Anonymous  Thank you for your help, both worked fine 🙂

Greg_Deckler
Community Champion
Community Champion

@bedata1 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler thank you for the links and information. 

Would it be possible for you to adjust the DAX formula with your instructions? 

@bedata1 Well, I would think something like:

Latest_Version Total = 
  VAR __GT = SUMX( SUMMARIZE( 'Sales Line Archive', [Document No_], "__Value", [Latest_Version] ), [__Value] )
  VAR __Result = IF( HASONEVALUE( 'Sales Line Archive'[Document No_] ), [Latest_Version], __GT )
RETURN
  __Result


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thank you Greg, that works.
The only problem I still have is that I have two different dates and so it shows the total on both dates.
How can I add the MAX Date to the DAX formula so that I only get one line?

bedata1_0-1714715266895.png

 

Anonymous
Not applicable

Hi @Greg_Deckler ,thanks for the quick reply, I'll add further.

Hi @bedata1 ,

I've assumed some data that you can modify based on the DAX expression I provided.

vzhouwenmsft_0-1714977332573.png

Measure = 
VAR _a = CALCULATE( MAX('Table'[Date]),ALLEXCEPT('Table','Table'[Type]))
VAR _b = MAXX(SUMMARIZE('Table',[Type],"Amount",MAX('Table'[Amount])),[Amount])
RETURN IF( SELECTEDVALUE('Table'[Date]) <> _a,BLANK(),_b)

vzhouwenmsft_1-1714977437323.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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