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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

cumulative total not summing up correctly

Hello,

I have written a measure for cumulative total, but it is not working properly for instance where the values are same for different entity.

Below is the snapshot. I have also shared PBIX file in below link(We transfer link).

https://we.tl/t-GSnPs1mL6t

Cumulative Pic.jpg

 

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

Normally I would take a lot more time to explain what I did but I am in a real hurry so here is the solution:

Measure 2 = 
VAR _curRuleType = SELECTEDVALUE(Data[Rules Type])
VAR _filter = ALLEXCEPT(Data, Data[City], Data[Offence Count])
VAR _summaryTable = SUMMARIZE(_filter, [Rules Type], "TMargin", [Total Margin])
VAR _rankedTable = ADDCOLUMNS(_summaryTable, "Ranked", 
    VAR curRuleType = [Rules Type]
    RETURN
        RANKX(_summaryTable, 
            RANKX(_summaryTable, [TMargin], , DESC, Skip) +
            DIVIDE(RANKX(_summaryTable, [Rules Type], , ASC, Skip), COUNTROWS(_summaryTable) + 1),
        ,DESC,Skip)
        )
VAR _curRank = MAXX(FILTER(_rankedTable, [Rules Type] = _curRuleType), [Ranked])
RETURN
SUMX(FILTER(_rankedTable, [Ranked] >= _curRank), [TMargin])

Resulting in the following in your PBIX:

image.png

If you have any questions, please don't hesitate to ask and I will return tomorrow 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

Normally I would take a lot more time to explain what I did but I am in a real hurry so here is the solution:

Measure 2 = 
VAR _curRuleType = SELECTEDVALUE(Data[Rules Type])
VAR _filter = ALLEXCEPT(Data, Data[City], Data[Offence Count])
VAR _summaryTable = SUMMARIZE(_filter, [Rules Type], "TMargin", [Total Margin])
VAR _rankedTable = ADDCOLUMNS(_summaryTable, "Ranked", 
    VAR curRuleType = [Rules Type]
    RETURN
        RANKX(_summaryTable, 
            RANKX(_summaryTable, [TMargin], , DESC, Skip) +
            DIVIDE(RANKX(_summaryTable, [Rules Type], , ASC, Skip), COUNTROWS(_summaryTable) + 1),
        ,DESC,Skip)
        )
VAR _curRank = MAXX(FILTER(_rankedTable, [Rules Type] = _curRuleType), [Ranked])
RETURN
SUMX(FILTER(_rankedTable, [Ranked] >= _curRank), [TMargin])

Resulting in the following in your PBIX:

image.png

If you have any questions, please don't hesitate to ask and I will return tomorrow 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Wow..!! thats a big caluclation for small looking task.

Is there any other way to simplyfy the calculation/Measure?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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