cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## Sum of the Sum

Hello,

I hope find you well.

I have a problem.
To have the sum per line I used the measure:

.TotalValue_StatusY =
CALCULATE(SUM(Table[Value]),
'Table'[Status]="y",
'Table'[Version]=MAX('Table'[Version])

But at the total level I have the sum of all values with status "y" when my purpose is to have only the sum of the latest version of status "y".
Can you help me?

Example:

1 ACCEPTED SOLUTION
Community Support

After understanding your problem, here is the solution I have for you.

This is the original table data. The name of the table is Table.

Create a measure that selects the maximum version of the ID with Status being y.

``````Measure = var _maxversion=CALCULATE(max('Table'[Version]), FILTER(ALLSELECTED('Table'),'Table'[ID]=SELECTEDVALUE('Table'[ID])&&  'Table'[Status]="y"))
return CALCULATE(sum('Table'[Value]), FILTER( 'Table' ,  'Table'[Version]=_maxversion&&'Table'[Status]="y"))``````

Create another measure that shows the total value of the calculation.

``TotalValue = SUMX(VALUES('Table'[ID]),[Measure])``

Then the desired results can be achieved.

Best regards,

Erica Wu

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

9 REPLIES 9
Community Support

After understanding your problem, here is the solution I have for you.

This is the original table data. The name of the table is Table.

Create a measure that selects the maximum version of the ID with Status being y.

``````Measure = var _maxversion=CALCULATE(max('Table'[Version]), FILTER(ALLSELECTED('Table'),'Table'[ID]=SELECTEDVALUE('Table'[ID])&&  'Table'[Status]="y"))
return CALCULATE(sum('Table'[Value]), FILTER( 'Table' ,  'Table'[Version]=_maxversion&&'Table'[Status]="y"))``````

Create another measure that shows the total value of the calculation.

``TotalValue = SUMX(VALUES('Table'[ID]),[Measure])``

Then the desired results can be achieved.

Best regards,

Erica Wu

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

Frequent Visitor

This works perfectly! Thank you very much 😊

Super User

``````measure =
SUMX(
FILTER(
'Table','Table'[version ] =CALCULATE(MAX('Table'[version]),
'Table'[status]="y",ALLEXCEPT('Table','Table'[id]))
),
'Table'[value]
)``````

Frequent Visitor

But this solution gives me this:

Thanks anyway 😊

Super User

with above data you provide my measure give as you want

but it seems something another thing present in your real data.

see below screenshort

Super User

Try this:

``````TotalValue_StatusY =
SUMX(VALUES(Table[ID]),
CALCULATE(SUM('Table'[Value]),
'Table'[Status]="y",
'Table'[Version]=MAX('Table'[Version])))``````
Frequent Visitor

But this solution gives me this:

Thanks anyway 😊

Community Champion

Certainly! Based on your description, you want to calculate the sum of values where the status is "y" but only for the latest version.

To achieve this, you can make use of the FILTER function along with the MAX function. Here's how you can modify your DAX measure to get the desired result:

.TotalValue_StatusY =
VAR MaxVersion = CALCULATE(MAX('Table'[Version]), 'Table'[Status] = "y")
RETURN
CALCULATE(
SUM('Table'[Value]),
'Table'[Status] = "y",
'Table'[Version] = MaxVersion
)

Here's a breakdown of what's happening in the measure:

1. We first calculate the maximum version number where the status is "y" using the CALCULATE and MAX functions and store it in the variable MaxVersion.
2. Then, using the CALCULATE function again, we filter the table to only consider rows where the status is "y" and the version matches the MaxVersion. Finally, we sum up the values for these filtered rows.

By using this measure, you should get the sum of values for the latest version where the status is "y".

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

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Frequent Visitor

But this solution gives me this:

Thanks anyway 😊

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

#### Power BI Monthly Update - July 2024

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

#### Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors