Skip to main content
Question

Count instances of value in table prior to date

  • May 23, 2024
  • 0 replies
  • 337 views

Forum|alt.badge.img+7

Hi everyone,

I'm trying to find a way to create a field that counts the # of times an email address exists within a table based on a date field within that record.

Example: Record is created with an email address and a date of interaction.  Goal - return the # of times that email address already exists in other records on or before the date of that interaction.

My formula query currently is: Size(GetRecords("{145.OBF.'" & [Date of Interaction] & "'}"))

Which DOES work, but it's counting huge numbers, and I don't understand why.  The results are in the thousands, for an email address that if I search for it, only exists 21 times.  

I *think* it's because my field 145 is also a formula query which reads - Trim(If([NEW Contact Email Address]="",[Contacts Table Field - Email Address],[NEW Contact Email Address]))

I'm wondering if it's not counting the results in the field, but query; however, when I switched the field to the field 'NEW Contact Email Address] I returned tens of thousands of records rather than the very few times a staff member manually entered it as a 'NEW' contact rather than looking up the email from our contacts table.

Ideas? and thank you!  

This topic has been closed for replies.

Forum|alt.badge.img+7
  • Author
  • Quickbase Alumni
  • May 23, 2024

Just an update - I'm still trying to understand the Count vs. Size functions; if I do 'Count' I'm returning a '1' value for every single record ...  I'm just missing something probably very simple here


Forum|alt.badge.img+7
  • Author
  • Quickbase Alumni
  • May 23, 2024

I've also tried a variation on a query posted by MarkShnier , but I'm not able to get a distinct count - it's only returning zeros:

var text QUERY = 
  "{145.EX.'" & ("{145.OBF.'" &[Date of Interaction]) & "'}";

Size(
GetRecords($QUERY))


MarkShnierYou
Forum|alt.badge.img+22
  • Quickbase Alumni
  • May 24, 2024

try this

var text QUERY =

"{99.EX.'" & [my email field] & "'}

& " AND "

& "{145.OBF.'" &[Date of Interaction]) & "'}";

Size(
GetFieldValues(
GetRecords($QUERY),3))

 

// change the 99 to the fid of your email field.