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.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Calculate percent using prior group in same column

Author  Topic 

SQLness
Starting Member

2 Posts

Posted - 2013-11-05 : 13:22:12
Trying to duplicate functionality of an excel sheet which calculates percentages within same column using prior group values. Not sure how to construct such a data set.
The column is part of a pivot with an integer value representing a sum.

For example:
GroupVal1
Val1
Val2
Val3
GroupVal2
Val1
Val2
Val3

Need to create a data set to calculate GroupVal2/GroupVal1, (Groupval2) Val1/ GroupVal1 Val1, etc. for all the detail rows.

Any suggestions what SQL to use for this?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-05 : 14:34:10
Did you try using ReportItems collection?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

SQLness
Starting Member

2 Posts

Posted - 2013-11-06 : 12:54:38
Yes, but they are not in the same group, so not in scope.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-06 : 13:10:50
did you try using rownumber function?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -