Get the total count of features purchased | Community
Skip to main content
Level 5
June 18, 2024
Solved

Get the total count of features purchased

  • June 18, 2024
  • 1 reply
  • 553 views
Hi there, 
 

I have an enrichment activity that divides the feature column into 4 parts. Now, I need to calculate how many features purchased, knowing that a customer can purchase one or more features. I am implementing this using a JavaScript function. Please advise on how to accomplish this.

vars.recCount currently retrieves the total number of records.

 

Thank you in advance

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ALangridge

Hello! Maybe try doing an enrichment, adding a new field and putting something together in the expression editor like:

Case(When(<field1> = NULL, 0),Else(1) ) + Case(When(<field2> = NULL, 0),Else(1) ) + Case(When(<field3> = NULL, 0),Else(1) ) + Case(When(<field4> = NULL, 0),Else(1) )

 

Each of the : Case(When(<field1> = NULL, 0),Else(1) ) parts just checks to see if your specific field is empty or not, then returns 0/1 depending on if it is. After that, it'll sum the numbers together and you get your count of how many of the product fields are filled/not.  Just make sure you update each of the <field1/2/3> parts to be your specific fields.

1 reply

ALangridge
ALangridgeAccepted solution
Level 4
June 19, 2024

Hello! Maybe try doing an enrichment, adding a new field and putting something together in the expression editor like:

Case(When(<field1> = NULL, 0),Else(1) ) + Case(When(<field2> = NULL, 0),Else(1) ) + Case(When(<field3> = NULL, 0),Else(1) ) + Case(When(<field4> = NULL, 0),Else(1) )

 

Each of the : Case(When(<field1> = NULL, 0),Else(1) ) parts just checks to see if your specific field is empty or not, then returns 0/1 depending on if it is. After that, it'll sum the numbers together and you get your count of how many of the product fields are filled/not.  Just make sure you update each of the <field1/2/3> parts to be your specific fields.