Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: martinh1976Hi - am trying to convert differing values based on what I refer to as a unit of measure.
The data I have relates to call usage and is stored in a billing system as follows:
| USAGE_UNITS |
UNIT_OF_MEASURE |
| 1024 |
KB |
| 120 |
TEXT |
| 140 |
SECONDS |
| 1000 |
EVENT |
| 2048 |
KB |
I want to convert based on the unit of measure to the following where KB is translated to MB, seconds is translated to hh:mm:ss and SMS/EVENTs are just passed through without any conversion
| USAGE_UNITS |
NEW_USAGE_UNITS |
| 1024 |
1 |
| 120 |
120 |
| 140 |
00:02:20 |
| 1000 |
1000 |
| 3000 |
2.92 |
I have tried to convert using a filter node but have struggled with the formatting for the time based translation, below is what I have so far.
emit*
if 'UNIT_OF_MEASURE' == "VOICE" then
{
AMOUNT = 'USAGE_UNITS')/60
}
else
if 'UNIT_OF_MEASURE' == "DATA" then
{
AMOUNT = 'USAGE_UNITS'/1024
}
else
if 'UNIT_OF_MEASURE' == "SMS" then
{
AMOUNT = 'USAGE_UNITS'
}
else
if 'UNIT_OF_MEASURE' == "EVENT" then
{
AMOUNT = 'USAGE_UNITS'
}
override emit AMOUNT, UNIT_OF_MEASURE
Any help appreciated.
Thanks
Martin