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
sarahp
Frequent Visitor

PowerBI Cumulative Total / Duplicate Values

Hi all,

 

I have been struggeling with this problem for quite a while now.

I’m trying to calculate a cumulative total of IssueId’s for each category. 

The formula I have now looks like this:

 

Cumulative Issues = 


Var TotalIssues = CALCULATE(COUNT(IssueStatus[IssueId]),ALLSELECTED(IssueStatus))

Var CurrentIssues = COUNT(IssueStatus[IssueId])

Var SummarizedTable =

summarize(

ALLSELECTED(IssueStatus),

(IssueCategoryHierarchy[Hierarchy_L2_Text]),

"XZ", COUNT(IssueStatus[IssueId])

)

Var CumulativeSum =

Sumx(

FILTER(SummarizedTable, [XZ] >= CurrentIssues ),

[XZ])

Return

CumulativeSum,

 

Unbenannt.PNG

 

Basically it adds up everything correctly, but as soon as duplicate values appear, it adds them up at once instead of adding them separately.

 

Any help is appreciated. Thank you!

6 REPLIES 6
lbendlin
Super User
Super User

Add a small random number to your values to break the ties.

Hi @lbendlin 

If i add a random number the statement and result look like this:

ISINSCOPE(IssueCategoryHierarchy[Hierarchy_L2_Text]),
Var TotalIssues2 = CALCULATE(COUNT(IssueStatus[IssueId]),ALLSELECTED(IssueStatus))
Var CurrentIssues2 = COUNT(IssueStatus[IssueId])
Var SummarizedTable2 =
summarize(
ALLSELECTED(IssueStatus),
(IssueCategoryHierarchy[Hierarchy_L2_Text]),
"XZ", [NumberOfIssueId]
)
Var CumulativeSum2 =
Sumx(
FILTER(SummarizedTable2, [XZ] >= CurrentIssues2 ),
[XZ] )
Return
CumulativeSum2,
Unbenannt2.PNG

 

A little less small? Does not need to be all positive either.

Could you please give me an example code?

Hi @sarahp ,

 

Would you please show us the expected output that we can help you well? 

 

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

 

Best Regards,

Dedmon Dai

for example 

 

x - 0.05 + RAND()*0.1

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.