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)
 Expression only calculating for first row

Author  Topic 

towardabettercountry
Starting Member

26 Posts

Posted - 2012-05-08 : 15:34:15
My other question

I have a couple of tables with around 20 rows each. I'm trying to calculate the difference between them in percentage, but it only calculates the difference for the first row. Then it goes on repeating that number for every other row. Here is my syntax:

=(Sum(Fields!Count.Value, "AMDS_PreviousCycle") - Sum(Fields!Count.Value, "AMDS_CurrentCycle")) / Sum(Fields!Count.Value, "AMDS_PreviousCycle")

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-08 : 16:50:47
you've having scope value as dataset i guess which is why it shows difference for entire dataset and repeats it for each item in table. probably you were looking for this

=(Sum(Fields!Count.Value) - Sum(Fields!Count.Value)) / Sum(Fields!Count.Value)

and I'm assuming the current container (tablix/table/matrix) is linked to AMDS_PreviousCycle dataset

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

towardabettercountry
Starting Member

26 Posts

Posted - 2012-05-08 : 18:07:38
Thanks for your reply. Let me clarify one part - I am dealing with two different datasets here (AMDS_CurrentCyle and AMDS_PreviousCycle).

Is there any way to calculate two different datasets with multiple rows? The rows of each dataset match. Just let me know if I'm misunderstanding.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-08 : 19:48:43
quote:
Originally posted by towardabettercountry

Thanks for your reply. Let me clarify one part - I am dealing with two different datasets here (AMDS_CurrentCyle and AMDS_PreviousCycle).

Is there any way to calculate two different datasets with multiple rows? The rows of each dataset match.
Just let me know if I'm misunderstanding.


Not possible to do row by row comparison between datasets inline in report

For that you should be bringing data joined from tables itself and doing your calculations also in t-sql query.
For report it should come from a single resultset having either component fields required for calculation or containing the calculated value itself.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

towardabettercountry
Starting Member

26 Posts

Posted - 2012-05-09 : 16:42:13
I understand. That gives me some direction. Thanks again for your help.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-09 : 21:19:03
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -