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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional sum

Status
Not open for further replies.

capri1966

Programmer
May 13, 2010
57
ES
Hello, i've a report that shows numbers but i need to show all numbers but sum only certain numbers on every row. ¿ How i can do this ?
 
Presumably there is some condition that determines which numbers you want to sum. If that's so, you need to do something like this:

1. Place the field to be summed in the Detail band (let's call this FieldA).

2. Place another field in the Detail band (FieldB). Set its expression to something like:

IIF(<condition>, FieldA, 0)

where <condition> is the expression that determines if you want to sum the value.

3. Calculate the sum of FieldB in the usual way.

4. Make FieldB invisible (e.g. by setting its foreground colour to the same as the report background colour).

I think that will give you what you want.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
If what you're really trying to say is that you need totals and only some rows should be included, take a look at Report Variables.

Tamar
 
I agree with Tamar Granor,

make a report variable and make it a sum for the field.

Ali Koumaiha
TeknoSoft Inc.
Michigan
 
Thank you to all, i've the solution adding a field with a 0 or 1 and when the value is 1 sum the value of a field
 
i've the solution adding a field with a 0 or 1 and when the value is 1 sum the value of a field

I would have thought that would give you the count rather than the sum. But if you're happy that it works, that's fine.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top