Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | Beginer2012Starting Member
 
 
                                        45 Posts | 
                                            
                                            |  Posted - 2012-05-16 : 09:32:26 
 |  
                                            | Hello,My dataset contains two column and ID column and a NumberOfCases columns.I'm calculating the percentage of each ID in the table by dividing each NumberOfcases by total numberOfCases. How ever I want to give a sum of these percentages in the Last row. How can I sum an expression in the table ?Thank youExample:ID NumberOfCases Percentage1     17          10.0 %2     28          16.5 %3     30          17.6 %4     45          26.5 %6     50          29.4 %Total 170 100 % ==========> I need this % total.The total of NumberOfCases is easy to get by having a sum on a field...But the percentage is not a field...It is calculated in an expresion in the table. |  |  
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2012-05-16 : 20:32:50 
 |  
                                          | you can add a similar expression for totalrow to make it calculate over the dataset.use scope as dataset name when applying the required aggregate functions.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |  
                                          |  |  |  
                                    | Beginer2012Starting Member
 
 
                                    45 Posts | 
                                        
                                          |  Posted - 2012-05-17 : 17:35:21 
 |  
                                          | Can you elaborate more please?? |  
                                          |  |  |  
                                    | SwePesoPatron Saint of Lost Yaks
 
 
                                    30421 Posts | 
                                        
                                          |  Posted - 2012-05-17 : 18:14:33 
 |  
                                          | Well, the sum will always be 100%, so why would you want to sum it? N 56°04'39.26"E 12°55'05.63"
 |  
                                          |  |  |  
                                    | vasu_thiaguStarting Member
 
 
                                    1 Post | 
                                        
                                          |  Posted - 2012-05-25 : 06:04:50 
 |  
                                          | Use this:select id, NoCases, NoCases*100/(select sum(NoCases) from Cases) from Cases |  
                                          |  |  |  
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2012-05-25 : 10:40:29 
 |  
                                          | quote:you can put expression like=SUM(Fields!yourfield.value,"your required scope here")for percentage you can yuse likeSUM(Fields!NumberOfcases.value)/SUM(Fields!NumberOfcases.value,"datasetname")------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/Originally posted by Beginer2012
 Can you elaborate more please??
 
 |  
                                          |  |  |  
                                |  |  |  |