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

Distinctcount shows 1 too many in totals

Status
Not open for further replies.

jeffm777

IS-IT--Management
Nov 10, 2009
108
US
Developing a report to show me the distinctcount of a string field. My group is based on this formula to show each month...

dim temp1
temp1 = Month({Class.DateEntered})
Select Case temp1
Case 1
formula = "January"
Case 2
formula = "February"
Case 3
formula = "March"
Case 4
formula = "April"
Case 5
formula = "May"
Case 6
formula = "June"
Case 7
formula = "July"
Case 8
formula = "August"
Case 9
formula = "September"
Case 10
formula = "October"
Case 11
formula = "November"
Case 12
formula = "December"
End Select

I'm doing a summary field in the group footer to show the distinctcount on each of these 4 formulas...

@threeYearsAgo:
if {Class.DateEntered} >= date(year(currentdate)-3,01,01) and {Class.DateEntered} <= date(year(currentdate)-3,12,31) then {Class.StockNum}

@twoYearsAgo:
if {Class.DateEntered} >= date(year(currentdate)-2,01,01) and {Class.DateEntered} <= date(year(currentdate)-2,12,31) then {Class.StockNum}

@oneYearAgo:
if {Class.DateEntered} >= date(year(currentdate)-1,01,01) and {Class.DateEntered} <= date(year(currentdate)-1,12,31) then {Class.StockNum}

@currentYear:
if {Class.DateEntered} >= date(year(currentdate),01,01) then {Class.StockNum}

Note: the StockNum field can never be null.

When it returns the data, it adds 1 to every month's total.

Any help would be greatly appreciated!
 
Found the answer...I had to change my formulas to the following:

if {Class.DateEntered} >= date(year(currentdate),01,01) then
1
else
0

Then I changed my summary field to SUM instead of distinctcount and the figures are correct.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top