Expand my Community achievements bar.

SOLVED

Calculations with numbers stored as text in s.eVar

Avatar

Level 6

My client captures price in an s.eVar, and I am trying to figure out if there is a way to use the captured value in mathematical operations within Adobe Analytics. I can export the data and treat the text string as a number using Python or other programming approaches, but would like to be able to handle this within Adobe because I could include calculations in Workspace. Since numeric classifications have been removed, I'm not sure if what I want is even possible. Does anyone have a recommendation for this?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I can see how you could potentially do this using a combination of regex in the classification rule builder and a calculated metric.  It's pushing the limits of what is achievable but it might just be do-able...

 

For the sake of explaining the concept let's simplify things by make the (false) assumption that your products range in value from $1 to $999 and are in whole numbers (you'll need to expand the concept to cover other values!).

 

First Stage: classifications

create 3 classifications, one for the units, one for the tens, and one for the hundreds.

Then use regex in the rule builder to dynamically split the value into the 3 classifications.  Your regex is going to look something like this:

For the units (^\d*)(\d$) returning $2

For the tens (^\d*)(\d)(\d$) returning $2

For the hundreds (^\d*)(\d)(\d)(\d$) returning $2

 

For example if the value was 874 then:

"units" classification would be dynamically set to "4"

"tens" classification would be dynamically set to "7"

"hundreds" classification would be dynamically set to "8"

 

Second Stage: calculated metric

You've now got to build a calculated metrics along the lines of:

 

If "unit" equals "1" static number 1

Plus

If "unit" equals "2" then static number 2

Plus

If "unit" equals "3" then static number 3

.

.

.

Etc. (all the way to 9)

Plus

If "tens" equals "1" then static number 10

Plus

If "tens" equals "2" then static number 20

Plus

If "tens" equals "3" then static number 30

.

.

.

Etc. (all the way to 90)

Plus

If "hundreds" equals "1" then static number 100

Plus

If "hundreds" equals "2" then static number 200

Plus

If "hundreds" equals "3" then static number 300

.

.

.

Etc. (all the way to 900)

 

Obviously in the real world you'll need to expand the concept for more digits.

 

It's pretty crazy but I think it would work.  Let me know if you try it!

View solution in original post

6 Replies

Avatar

Employee

You would not be able to run Mathematical operations at least within the UI for the sole reason that the evar values even if passed as numerical numbers would be passed as strings. I dont see any ways of this being achieved as per the current system configuration.

Avatar

Correct answer by
Community Advisor

I can see how you could potentially do this using a combination of regex in the classification rule builder and a calculated metric.  It's pushing the limits of what is achievable but it might just be do-able...

 

For the sake of explaining the concept let's simplify things by make the (false) assumption that your products range in value from $1 to $999 and are in whole numbers (you'll need to expand the concept to cover other values!).

 

First Stage: classifications

create 3 classifications, one for the units, one for the tens, and one for the hundreds.

Then use regex in the rule builder to dynamically split the value into the 3 classifications.  Your regex is going to look something like this:

For the units (^\d*)(\d$) returning $2

For the tens (^\d*)(\d)(\d$) returning $2

For the hundreds (^\d*)(\d)(\d)(\d$) returning $2

 

For example if the value was 874 then:

"units" classification would be dynamically set to "4"

"tens" classification would be dynamically set to "7"

"hundreds" classification would be dynamically set to "8"

 

Second Stage: calculated metric

You've now got to build a calculated metrics along the lines of:

 

If "unit" equals "1" static number 1

Plus

If "unit" equals "2" then static number 2

Plus

If "unit" equals "3" then static number 3

.

.

.

Etc. (all the way to 9)

Plus

If "tens" equals "1" then static number 10

Plus

If "tens" equals "2" then static number 20

Plus

If "tens" equals "3" then static number 30

.

.

.

Etc. (all the way to 90)

Plus

If "hundreds" equals "1" then static number 100

Plus

If "hundreds" equals "2" then static number 200

Plus

If "hundreds" equals "3" then static number 300

.

.

.

Etc. (all the way to 900)

 

Obviously in the real world you'll need to expand the concept for more digits.

 

It's pretty crazy but I think it would work.  Let me know if you try it!

Avatar

Level 6
That's an interesting approach. I had already created classifications for price groupings (e.g. $250, $500, etc. increments), and with prices up to $100,000 I may increased create these calculated metrics by group. Not quite the ideal, but it's worth experimenting with. Hopefully Adobe figures out a replacement for numeric classifications.

Avatar

Level 3
I've used a very similar approach to make Calculated Metrics based on Survey scores that have a possible range of 0 to 100; have to admit that I didn't come up with the additional step of converting into Units / Tens / Hundreds, which will save me some tedium next time!

Avatar

Level 3
One additional point: it may be worth "seeding" the values using Classification Importer (e.g., make a sheet with all of the values from $1 to $100000 and upload it) rather than the Classification Rule Builder approach. If you have decimals and are willing to forego that level of precision, use Classification Rule Builder to discard the decimal then "sub-classify" using Classification Importer as laid out here.

Avatar

Level 10
Do any of the answers below answer your initial question? If so, can you select one of them as the correct answer? If none of the answers already provided answer your question, can you provide additional information to better help the community solve your question?