Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Choose Post Reply Post New Topic
Author Message
RodSimpson
Newbie
Newbie


Joined: 23 Nov 2013
Location: Canada
Online Status: Offline
Posts: 2
Quote RodSimpson Replybullet Topic: Choose
     Posted: 26 Nov 2013 at 9:01am
Choose

({?Period}, NETPERD1, NETPERD2 , NETPERD3, NETPERD4, NETPERD5 , NETPERD6 , NETPERD7, NETPERD8 , NETPERD9, NETPERD10, NETPERD11, NETPERD12 )

This serves one requirement in that assuming the entered parameter is 7 then this return the amount in NETPERD7.

What I also need to be able to do is to return the sum of all the fields up to and including NETPERD7.

(NETPERD1 + NETPERD2 + NETPERD3 + NETPERD4 + NETPERD5 + NETPERD6 + NETPERD7)
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 26 Nov 2013 at 12:19pm
are this ({?Period}, NETPERD1, NETPERD2 , NETPERD3, NETPERD4, NETPERD5 , NETPERD6 , NETPERD7, NETPERD8 , NETPERD9, NETPERD10, NETPERD11, NETPERD12 )
separate fields or one field?
IP IP Logged
RodSimpson
Newbie
Newbie


Joined: 23 Nov 2013
Location: Canada
Online Status: Offline
Posts: 2
Quote RodSimpson Replybullet Posted: 26 Nov 2013 at 12:30pm
They are separate fields. All in the same table but individual fields were the accounting system keeps track of the changes in accounts.
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 26 Nov 2013 at 12:40pm
i dont see a simple solution for this if you know some SQL you could try to write a command like

select NETPERD1 as Type_id, value
from databasename.dbo.tablename
union all
select NETPERD2 as Type_id, value
from databasename.dbo.tablename
union all
select NETPERD3 as Type_id, value
from databasename.dbo.tablename
...
so that you could have it as a single field then the rest of it should be easy.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Nov 2013 at 3:48am
if I understand your data set correctly, you might also consider not trying to filter the data but rather conditionally display and then use a formula fields to get your sum
It really depends on what layout and other requirements are in the report.
 
The sum (for a row) can be accomplished with 1 formula
 
(NETPERD1)+
(if {?Period}>1 then NETPERD2)+
(if {?Period}>2 then NETPERD3)+
(if {?Period}>3 then NETPERD4)+
(if {?Period}>4 then NETPERD5)+ ...
 
 


Edited by DBlank - 27 Nov 2013 at 3:49am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 27 Nov 2013 at 4:50am
I'll throw in my 2 cents...

I agree with DBlank, I was going to structure my addition slightly differently, but the effect would be the same...

As is my usual response, if you can write a stored procedure, you should be able to accomplish all your goals in a much simpler fashion. Meaning that your stored procedure could return just the data from say period 7, and as an additional column the sum of all prior periods.

Although in reading the various responses, you are not filtering any data, just only displaying the value of the current period, but you want a running total of the periods...so DBlank's solution should work. The only caveat is that you won't be able to SUM his formula...but there are ways around that.

HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum