Compute a number dimension

Learn here how to compute numbers on your cards, using usual arithmetic with number dimensions and dimensions with a number associated

Compute a number dimension
Learn here how to compute numbers on your cards, using usual arithmetic with number dimensions and dimensions with a number associated
  1. What is a Compute a number dimension ?
    1. Example
  2. Where are raw numbers coming from?
  3. The expression language
    1. How to find the dimension codes ?
    2. How to write logic according to the dimension values of other dimensions ?
  4. Where to get help ?
  5. Going further

What is a Compute a number dimension ?

This kind of dimension enriches your card with data, like any other dimension. But the value on a card is not chosen manually in the card edition dialog, but is the result of a computation involving values provided by other dimensions on your card.

Example

Let's say that you have a number dimension called Budget, and you'd like to compute Budget with tax. The formula might be the following (for 21% of VAT):

Compute a number - example.png

Where are raw numbers coming from?

There are two sources of raw numbers to be used in larger expressions:

  1. Track any number dimensions provide a direct number encoded on cards themselves

  2. Dimensions with numbers attached to values. First you need to enable the option on the dimension itself and save it (CTRL-S):

    Compute a number - associate numbers.png

    Then you can associate numbers to values:

    Compute a number - semantics.png

The expression language

The expression language uses Elo, that can be used to compute any number you'd like. In those expressions:

  • _ denotes the current card, on which the computed value applies,
  • _.xxx denotes the card value along the dimension whose name is xxx (in snake_case format ; if your dimension is named Time spent, the variable is time_spent)
  • _.xxx.id denotes the identifier of the value, for dimensions with a list of values set on cards (simply use _.xxx for numbers, dates and free text)
  • _.xxx.semantics denotes the semantics value, for dimensions with numbers associated to values (second case of the earlier section)

How to find the dimension codes ?

In the formula editor, pressing _. should provide you with a suggestion showing the list of dimensions :

Compute a number - autocompletion.png

For a particular dimension, you'll find the code to use in formulas in the General panel when editing it :

Compute a number - dimension code.png

How to write logic according to the dimension values of other dimensions ?

Let's say that you want to write some complex logic for your tax percentage according to the type of product, tracked in another dimension :

Compute a number - logic on dimension values.png

The identifiers of the dimension values you can reference in such a formula can be found in the Values panel of the dimension details :

Compute a number - dimension value codes.png

Where to get help ?

Writing formulas is always a bit difficult for non-tech. Jump on our Klarocardistas community to get immediate help.

Going further

  • Starting with Klaro Cards 0.259.0, Klaro Cards uses Elo which is simple, clean and powerful. The documentation online is certainly worth a read.
  • For business instances on earlier versions, Klaro Cards still uses the Livescript language.

See also

Nothing to read here

You have no article in this section.

Go back

Article status changed.

Article status changed.

Article status changed.