Forum Discussion
Sum by multiple columns
Hi,
I have some stock data that shows products sent out and products returned, along with return reasons (row 2,3,4). I also have numbers for those sent out but not returned (row 1).
What I would like to work out is the rate of products returned for each reason and category. And this is calculated as the number of return divided by the total of products out by a particular set of variables (categories).
I need to get a measure/column that calculates this total product out by the set categories
e.g. In the sample below where market = abc, cat1=adult, cat2=womenswear, cat3=accessories and cat4=belt, the total is 153 (90+11+26+26).
At the moment, if i calculate in-rate, they come up as 100% which is wrong.
Sample data output
| Row | Market | Cat1 | Cat2 | Cat3 | Cat4 | Reas1 | Reas2 | Out | Return | In Rate |
| 1 | abc | Adult | Womenswear | Accessories | Belts | 90 | ||||
| 2 | abc | Adult | Womenswear | Accessories | Belts | Fit | Big | 11 | 11 | 100% |
| 3 | abc | Adult | Womenswear | Accessories | Belts | Other | Unknown | 26 | 26 | 100% |
| 4 | abc | Adult | Womenswear | Accessories | Belts | Styling | Unsuitable | 26 | 26 | 100% |
Desired data output
| Row | Market | Cat1 | Cat2 | Cat3 | Var4 | Reas1 | Reas2 | Out | Return | In Rate |
| 1 | abc | Adult | Womenswear | Accessories | Belts | 90 | ||||
| 2 | abc | Adult | Womenswear | Accessories | Belts | Fit | Big | 11 | 11 | 7% |
| 3 | abc | Adult | Womenswear | Accessories | Belts | Other | Unknown | 26 | 26 | 17% |
| 4 | abc | Adult | Womenswear | Accessories | Belts | Styling | Unsuitable | 26 | 26 | 17% |
The total in rate for cat4=belts is 43% - total in (63)/total out (153)
Hope this all makes sense and many thanks for your help!
afk
Cool try this
Percentage = SUM(Com1[Return])/CALCULATE(SUM(Com1[Out]),ALLEXCEPT(Com1,Com1[Cat4]))