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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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