SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


CAlculate debits and credit total in ssrs report


CAlculate debits and credit total in ssrs report

Author
Message
anuhya.mudumba
anuhya.mudumba
SSC Veteran
SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)

Group: General Forum Members
Points: 244 Visits: 304
Hi All.... Im struck up at this point since yesterday..Please help.

I have a an ageing report which shows all the amounts of the customer.
I have all the debitted and creditted amount of the customer in a single column that i get from a dataset. Based on the ageing i display the amount accordingly like records < 30 days, > 30 days and so. I have to find out the total of the column adn also the total of debitted amount and creditted amount separately.
Let me show how my report looks like :

CustomerGroup CustomerId Items< 30 Amount< 30 Items >30 Amount>30 TotalItems TotalAmount
AG 1 1 100 2 100 3 200
SI 11 0 0 1 -250 1 -250
LG 5 2 150 1 100 3 250
------------------------------------------------------------------------------------------------------
Total 3 250 4 -50 7 200
CR 0 -250 -250
DR 250 200 450



Iam able to find the grand totals of all the columns but finding it tough to find the total of cr and dr amounts.

With Regards,
Anu..;-)Hehe
LutzM
LutzM
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24173 Visits: 13559
would something like the following help?
SUM(CASE WHEN col1> 0 THEN col1 ELSE 0 END) AS DEBIT,
SUM(CASE WHEN col1< 0 THEN col1 ELSE 0 END) AS CREDIT



If not, please post table def and sample data of the underlying table in a ready to use format as described in the first link in my signature together with your expected result.



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
anuhya.mudumba
anuhya.mudumba
SSC Veteran
SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)

Group: General Forum Members
Points: 244 Visits: 304
Thanks Lutz for your reply...

I cannot use it in the sql part. The requiremment is such that i should get the raw data from the tables and perform all others transformations from the ssrs side. Also I need to display these credit and debit totals in the report footer.
I tried something like :

Iif (ReportItems!textbox1.Value < 0,Sum(ReportITems!textbox1.Value,0) in txtCRTotal textbox.

Iif(ReportItems!,textbox1.Value =0 OR ReportItems!.textbox1.Value>0, Sum(ReportITems!textbox1.Value),0)

But it is giving the error that multiple report items cannot be used.
If i pass a numeric values to the iif statement like,
IIF(ReportItems!textbox1.Value <0 , 1, 0) it works fine.

Is it something like we cannot pass reportitems in the iif statement ?

Any clue...?

With Regards,
Anu..;-)Hehe
LutzM
LutzM
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24173 Visits: 13559
anuhya.mudumba (9/5/2010)
Thanks Lutz for your reply...

I cannot use it in the sql part. The requiremment is such that i should get the raw data from the tables and perform all others transformations from the ssrs side. Also I need to display these credit and debit totals in the report footer.
...

It's kind of a philosophical question whether you consider using a query in SSRS as a data source (e.g. to preaggregate the data) instead of plain tables being part of SSRS process or not... ;-)
I would question such a requirement.



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
anuhya.mudumba
anuhya.mudumba
SSC Veteran
SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)

Group: General Forum Members
Points: 244 Visits: 304
Hey Lutz......
U r right....i have the same doubts though but i instructed to bring the max benifits of using ssrs and it is one among them.
i have to do all the calculations , aggregations , grouping , sorting, everything only in ssrs and not strictly in sql Crying
And this one is eating out my mind.....
Any help ???

With Regards,
Anu..;-)Hehe
LutzM
LutzM
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24173 Visits: 13559
anuhya.mudumba (9/6/2010)
Hey Lutz......
U r right....i have the same doubts though but i instructed to bring the max benifits of using ssrs and it is one among them.
i have to do all the calculations , aggregations , grouping , sorting, everything only in ssrs and not strictly in sql Crying
And this one is eating out my mind.....
Any help ???


All I can do is to repeat what I stated before: building a query as a data source in SSRS will fulfill the requirement to use SSRS only. T-SQL is part of SSRS, too.



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Tom Garth
Tom Garth
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2013 Visits: 1499
anuhya.mudumba (9/5/2010)
Thanks Lutz for your reply...

I cannot use it in the sql part. The requiremment is such that i should get the raw data from the tables and perform all others transformations from the ssrs side. Also I need to display these credit and debit totals in the report footer.
I tried something like :

Iif (ReportItems!textbox1.Value < 0,Sum(ReportITems!textbox1.Value,0) in txtCRTotal textbox.

Iif(ReportItems!,textbox1.Value =0 OR ReportItems!.textbox1.Value>0, Sum(ReportITems!textbox1.Value),0)

But it is giving the error that multiple report items cannot be used.
If i pass a numeric values to the iif statement like,
IIF(ReportItems!textbox1.Value <0 , 1, 0) it works fine.

Is it something like we cannot pass reportitems in the iif statement ?

Any clue...?


I think you want to sum the result of the conditional like this...
Sum(Iif (ReportItems!textbox1.Value < 0,ReportITems!textbox1.Value,0)) in txtCRTotal textbox.
Sum(Iif (ReportItems!textbox1.Value > 0,ReportITems!textbox1.Value,0)) in txtDBTotal textbox.
I hope I got it right, but I couldn't test it. I hope you get the idea though.

Tom Garth
Vertical Solutions

"There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers

anuhya.mudumba
anuhya.mudumba
SSC Veteran
SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)

Group: General Forum Members
Points: 244 Visits: 304
Thanks Tom...
I already tried the expression u mentioned but i got the error as :

The Value expression for the textbox txtCRTotal refers to more than one report item. An expression in a page header or footer can refer to only one report item.
The expression I tried is :
SUM(IIF ( ReportItems!txtNoOfItems30.Value < 0 ,ReportItems!txtNoOfITems30.value , 0))

I used the above expression in the page footer.

The report executes well if I pass numerics as iif result sets.

With Regards,
Anu..;-)Hehe
Tom Garth
Tom Garth
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2013 Visits: 1499
Doesn't summing the same conditional for the detail row values get you what you want?

Tom Garth
Vertical Solutions

"There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers

Daniel Bowlin
Daniel Bowlin
SSCrazy Eights
SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)

Group: General Forum Members
Points: 8122 Visits: 2629
If I understand correctly:
You want to totals of the debits and of the credits.
The debits and credits do not show individually in the detail because you have put them in a single column.
You, for some reason, are restricted from doing this in the SQL of the data set

I think you might find it easier to make 2 hidden columns in your detail. One for credits and one for debits. Once you have the debits and credits in separate columns, you should find it much easier to get totals for each.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search