Expand my Community achievements bar.

SOLVED

Get the total count of features purchased

Avatar

Level 6
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

1 Accepted Solution

Avatar

Correct answer by
Level 4

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.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 4

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.