A usage structure might be complex and tricky to set up.
To make it easier and more flexible to process complex usage into Younium, we have the pre-processing rules feature, making it possible to pre-process the usage into Younium according to your own customized rules.
These rules can be applied to all the key levels (Account, Order, Product, Charge).
Navigation
If you want to add usage pre-processing rules, go to Usage, press the three dots, and then Preprocessing rules
Press ADD RULE, name your rule, enter your statement, and then press SAVE
Example
One example of a common issue in setting up the usage flow can be clients with multiple usage keys that correspond to only one charge.
Let's say we have the field "usagekey" on the charge level to which we map usage. We have an account, Bob's Business, that uses our product in two countries, Sweden and Norway. We measure the usage on a country-level, meaning that we gather usage data per each country, and therefore, we have two separate keys for the usage. Our order, however, only has one charge, to which all usage will go.
To merge these two usage rows into the one on the charge, this would be our preprocessing rule:
Remember to check the Use preprocessing rules box when importing the usage.
Documentation
Rule
The following formats are allowed for pre-processing rules
(expression)
if (condition) then (expression)
if (condition) then (expression) else (expression)
Examples
if {{FieldA}} = 'some value' then skip
Behavior: If the value in column named FieldA equals some value
then skip this line
if {{FieldA}} in (1,2,3) then {{FiledB}} = 'small' else {{FieldB}} = 'large'
Expressions
Assignment
Skipskip
Condition operators
<
<=
>=
<>
=
IN
LIKE
Expression operators
The following arithmetic operators are also supported in expressions:
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
% (modulus)
String Operators
To concatenate a string, use the + character. [TBD: String case sensitivity]
Wildcard Characters
Both the * and % can be used interchangeably for wildcard characters in a LIKE comparison. If the string in a LIKE clause contains a * or %, those characters should be enclosed in brackets ([]). If a bracket is in the clause, each bracket character should be enclosed in brackets (for example [[] or []]). A wildcard is allowed at the start and end of a pattern, or at the end of a pattern, or at the start of a pattern. For example:
{{Filed A}} LIKE '*product*'
{{Field A}} LIKE '*product'
Wildcard characters are not allowed in the middle of a string. For example, 'te*xt' is not allowed.
Functions
The following functions are also supported:
CONVERT
Description Converts a particular expression to a specified .NET Framework Type.
Syntax Convert(expression, type)
Arguments expression -- The expression to convert.
type The .NET Framework type to which the value will be converted.
Example: Convert({{Total}}, 'System.Int32')
All conversions are valid with the following exceptions: Boolean can be coerced to and from Byte, SByte, Int16, Int32, Int64, UInt16, UInt32, UInt64, String and itself only. Char can be coerced to and from Int32, UInt32, String, and itself only. DateTime can be coerced to and from String and itself only. TimeSpan can be coerced to and from String and itself only.
LEN
Description Gets the length of a string
Syntax LEN(expression)
Arguments expression -- The string to be evaluated.
Example: Len({{FieldA}})
ISNULL
Description Checks an expression and either returns the checked expression or a replacement value.
Syntax ISNULL(expression, replacementvalue)
Arguments expression -- The expression to check.
replacementvalue -- If expression is null, replacementvalue is returned.
Example: IsNull({{Field A}}, -1)
IIF
Description Gets one of two values depending on the result of a logical expression.
Syntax IIF(expr, truepart, falsepart)
Arguments expr -- The expression to evaluate.
truepart -- The value to return if the expression is true.
falsepart -- The value to return if the expression is false.
Example: IIF({{Price}}>1000, 'expensive', 'cheap')
TRIM
Description Removes all leading and trailing blank characters like \r, \n, \t, ' '
Syntax TRIM(expression)
Arguments expression -- The expression to trim.
SUBSTRING
Description Gets a sub-string of a specified length, starting at a specified point in the string.
Syntax SUBSTRING(expression, start, length)
Arguments expression -- The source string for the substring.
start -- Integer that specifies where the substring starts.
length -- Integer that specifies the length of the substring.
Example: SUBSTRING({{FieldX}}, 7, 8)