Forum Discussion
Running Total Breaks when Adding Top N
- 5 years ago
Sburi2
I made a sample file. as you can see, I filtered by top 3, and still, the result is correct. In your initial posting of the question, you had used ALLSELECTED when you calculated the all appname total, you should use ALL. check my formula below: I attached the file as well.Cummulative = var __current = [Total Sales] var __all = CALCULATE( [Total Sales] , ALLSELECTED(financials[Product])) var __cumm = CALCULATE( [Total Sales], FILTER( ALLSELECTED(financials[Product]), [Total Sales] >= __current ) ) return DIVIDE( __cumm , __all ) - 5 years ago
Sburi2
When you posted the question initially, I noticed that you had used ALL instead of ALLSELECTED. It was one reason for the incorrect results when you applied TOPn filter. Apart from that you also had applied some other filters.ar __all = CALCULATE( [Total Sales] , ALLSELECTED(financials[Product]))
Sburi2
I made a sample file. as you can see, I filtered by top 3, and still, the result is correct. In your initial posting of the question, you had used ALLSELECTED when you calculated the all appname total, you should use ALL. check my formula below: I attached the file as well.
Cummulative =
var __current = [Total Sales]
var __all = CALCULATE( [Total Sales] , ALLSELECTED(financials[Product]))
var __cumm =
CALCULATE(
[Total Sales],
FILTER(
ALLSELECTED(financials[Product]),
[Total Sales] >= __current
)
)
return
DIVIDE( __cumm , __all )
That's so odd... I open up your file and it works. I open up my file and it doesn't. I compare the DAX formulas and they are functionally the same. I'm not sure where I'm going wrong.
I also just noticed that it actually is performing a cumulative count, but only when the previous numbers exactly equal the current numbers. I'm not using =, I'm using >=... not sure what's wrong.
- Fowmy5 years agoSuper User
I am not sure how your model is setup.
Share your dax formula to check.
you can also attach a sample file like I did, save it in OneDrive or any other cloud location and share the link- Sburi25 years agoNew Member
Same formula as before essentially. Would share the file but the data is confidential of course and if I simplify it I'll end up with a (less clean) version of your file 🙂
I did find out what was causing the issue but not why. I have another filter on the page on the column with the monthly cost. I'm filtering out things that are = 0. For some reason, having this filter applied breaks the cumulative function.