Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing a an aggregated value with 0 within an IF condition

Status
Not open for further replies.
Aug 27, 2003
428
US
Hi

Can I replace an aggregated value with 0?

example

IF Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SubSectionID}) = 0 THEN
Sum ({rptRevenueFinancials_Detail.TradeVolumeDate) = 0.

I am grouping by SubSectionID and summming by TradeVolumeDate.

I get a syntax error.

What is wrong?

Thanks
 
i believe you would need to use a variable to display:

{@onetwo}
numbervar S1;
IF Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SubSectionID}) = 0 THEN
S1 := 0 ELSE Sum ({rptRevenueFinancials_Detail.TradeVolumeDate)
 
Hi,
Try
Code:
IF Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SubSectionID})  = 0 
THEN
0
Else
Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SubSectionID})

You cannot assign a value to a SUM calculation -



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I like Turkbear's response better than mine.


but...I left off the S1 := after the ELSE...mine should have read:

{@onetwo}
numbervar S1;
IF Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SubSectionID}) = 0 THEN
S1 := 0 ELSE S1 := Sum ({rptRevenueFinancials_Detail.TradeVolumeDate)
 
What is wrong with this formula? I want to assign the below value whenthe variable is > 0

numbervar S1;
IF {rptRevenueFinancials_Detail.SubSectionID} = 120 THEN
S1 := 0 ELSE S1 := Sum ({rptRevenueFinancials_Detail.FeeDate},{rptRevenueFinancials_Detail.SubSectionID})


If S1 > 0 then S1 / (Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SectionID})) * 1000


 
Can anyone help with the formula that I posted earlier please?

I want to do two steps.

numbervar S1;
IF {rptRevenueFinancials_Detail.SubSectionID} = 120 THEN
S1 := 0 ELSE S1 := Sum ({rptRevenueFinancials_Detail.FeeDate},{rptRevenueFinancials_Detail.SubSectionID})


If S1 > 0 then S1 / (Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SectionID})) * 1000



 
Hi,
try:

Code:
Local numbervar S1;
IF {rptRevenueFinancials_Detail.SubSectionID}  = 120
 THEN 
S1 := 0 
ELSE  S1 := Sum ({rptRevenueFinancials_Detail.FeeDate},{rptRevenueFinancials_Detail.SubSectionID}) ;
If S1 > 0
 then 
S1 / (Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SectionID})) * 1000
Else
0



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Try adding 'whileprintingrecords' to the top of your formula(s).


A few questions to help me make fewer mistakes in my suggestions:
Are you trying to do it in 2 formulas?
Are you wanting to display both the numerator and the calculated percent?
Is your raw data all numeric fields?
Are there null values possible in your data?
Are you getting an error message when you try to run it, or incorrect results? either way, what is it/are they?



Formula 1:
//{@evalsubID}
whileprintingrecords;while
numbervar S1;
IF {rptRevenueFinancials_Detail.SubSectionID} = 120 THEN
S1 := 0 ELSE S1 := Sum ({rptRevenueFinancials_Detail.FeeDate},{rptRevenueFinancials_Detail.SubSectionID})

Formula 2:
//{@calcpct}
whileprintingrecords;
numbervar S1
If S1 > 0 then S1 / (Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SectionID})) * 1000
 

Yes in two formulas.
Yes all numeric fields.
Incorrect results when i try to run it.

I am not sure about question 2 and 4 respectively. I gried the above formula and got the below error on the second.

The remaining text does not appear to be part of the formula.
If S1 > 0 then S1 /
(Sum({rptRevenueFinancials_Detail.TradeVolumeDate},{rptRevenueFinancials_Detail.SectionID})) * 1000
 
Sorry, i forgot a ';' after the numbervar S1 on Formula 2.
Formula 2:
//{@calcpct}
whileprintingrecords;
numbervar S1;
If S1 > 0 then S1 / (Sum ({rptRevenueFinancials_Detail.TradeVolumeDate}, {rptRevenueFinancials_Detail.SectionID})) * 1000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top