Forum Discussion
Cumulative % Total in Canvas
- Anonymous2 years ago
Hi BenediktW
Based on the code you provided, you seem to be calculating the total sales and sales per customer correctly.
However, accumulating sales seems to be the problem. To calculate the running cumulative percentage, you need to make sure that the cumulative sales are calculating the cumulative values correctly in the table.
I made some simple changes to your code.
Here's some dummy data.
"Table"
Modified code:
Cumulative % Total = var currentCustomer = MAX('Table'[Customers]) var TotalSales = CALCULATE( SUM('Table'[Sales]), ALLSELECTED('Table') ) var CumulativeSales = CALCULATE( SUM('Table'[Sales]), FILTER( ALLSELECTED('Table'), 'Table'[Customers] <= currentCustomer ) ) RETURN DIVIDE(CumulativeSales, TotalSales)Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi BenediktW
Based on the code you provided, you seem to be calculating the total sales and sales per customer correctly.
However, accumulating sales seems to be the problem. To calculate the running cumulative percentage, you need to make sure that the cumulative sales are calculating the cumulative values correctly in the table.
I made some simple changes to your code.
Here's some dummy data.
"Table"
Modified code:
Cumulative % Total =
var currentCustomer = MAX('Table'[Customers])
var TotalSales =
CALCULATE(
SUM('Table'[Sales]),
ALLSELECTED('Table')
)
var CumulativeSales =
CALCULATE(
SUM('Table'[Sales]),
FILTER(
ALLSELECTED('Table'),
'Table'[Customers] <= currentCustomer
)
)
RETURN DIVIDE(CumulativeSales, TotalSales)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.