SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Switch Formula Add up depend on Month for Report
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

micnie_2020
Posting Yak Master

Malaysia
227 Posts

Posted - 03/30/2014 :  12:57:21  Show Profile  Reply with Quote
Hi All,

I have this:-

=Switch(Fields!Months.Value="Apr",Fields!amount.Value,Fields!Months.Value="May",Fields!amount.Value,Fields!Months.Value="Jun",Fields!amount.Value,Fields!Months.Value="Jul",Fields!amount.Value,Fields!Months.Value="Aug",Fields!amount.Value,Fields!Months.Value="Sep",Fields!amount.Value,Fields!Months.Value="Oct",Fields!amount.Value,Fields!Months.Value="Nov",Fields!amount.Value,Fields!Months.Value="Dec",Fields!amount.Value,Fields!Months.Value="Jan",Fields!amount.Value,Fields!Months.Value="Feb",Fields!amount.Value,Fields!Months.Value="Mar",Fields!amount.Value)

I try modify to:
=Switch(Fields!Months.Value="Apr",Fields!amount.Value,Fields!Months.Value="May",Fields!amount.Value+IIF(Fields!Months.Value="Apr",Fields!amount.Value,0)....

Eg: But it's not add up apr & may for May amount


The output required as
1) if Fields!Months.Value="May" supposed to add up amount for month Apr & May
2) if Fields!Months.Value="Jun" supposed to add up amount for month Apr & May & Jun
3) if Fields!Months.Value="Jul" supposed to add up amount for month Apr & May & Jun & Jul
:
:
Please advise.

Thank you.

Regards,
Micheale

Edited by - micnie_2020 on 03/30/2014 13:08:33

sqlsaga
Yak Posting Veteran

USA
93 Posts

Posted - 03/31/2014 :  12:00:52  Show Profile  Reply with Quote
Looks like you are creating this formula in SSRS, What is your source? SQL Database or SSAS cube? If it's a SQL Query, you can always use a running total concept and build up the sum from the next immediate month and display that in the report. For SSAS, you can write an MDX script and make it happen.

For an article about Running totals for a SQL Database, look at this link.. http://sqlsaga.com/sql-server/how-to-calculate-running-totals-in-sql-server/



Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000