Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Sum Based on The Value of Another Group

$
0
0

 

I'm using RS 2005 and trying to accomplish the following:

 

Here is the detail data for those customers with negative balance. For example cust2 = -50 and cust3 = -30

Cust ID    Ord #   Balance

cust1        1          30

cust1        2          80
cust2        1        100
cust2        2       -150

cust3        1        100
cust3        2         70
cust3        3       -200

cust4        1       100

cust4        2         50

cust5        1       250

cust5        2         20

 

Total (net) balance for cust1 is 110

Total (net) balance for cust2 is -50 (100 + -150)

Total (net) balance for cust3 is -30 (100 + 70 + -200)

Total (net) balance for cust4 is 150

Total (net) balance for cust5 is 270
i have to aggregate the customer balance in group A (group by Cust ID)

For group B, Division - I only want sum the  balance of the customers within that division that have a negative balance (the balance aggregate in group A).

 

so the Total for Division (group B) is  -80 (bal of cust2 + bal of cust3)

in summary, i have to aggregate the balance for each customer, base on the balance of each customer (neg bal only), i aggregate the balance for the Division.  Your help/suggestion is greatly appreciated.


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>