Skip to main content

unit

Definition

A number/integer can be in a certain unit, which should be shown to the end user.

In Veezoo, the unit feature allows you to display the relevant units of measure or currency for an attribute in your data visualizations. This ensures that any key performance indicators (KPIs) or other metrics are presented with the appropriate context, making your data visualizations more meaningful and easier to understand.

For example, if you are visualizing financial data like revenue, you would want to display the relevant currency alongside the values.

Usage

To define a unit for an attribute, you can use the unit keyword in your Veezoo Knowledge Layer (VKL) code. Here's an example where we define the unit for the revenue attribute:

kb {
class Transactions {
name.en: "Transactions"

...

number Revenue {
name.en: "Revenue"

sql: "${TRANSACTON.revenue}"

unit: onto.Currency.USD
}
}
}

In this example, the unit for the revenue attribute is set to onto.Currency.USD. So when a user asks something like "what is the total revenue", Veezoo will display the revenue values with a dollar sign ($), denoting that the values are in dollars.

Veezoo already comes with a selection of units, which you can find under:

onto.Currency.*

# Examples:
onto.Currency.USD
onto.Currency.EUR

onto.Percentage

onto.Unit.*

# Examples:
onto.Unit.meters
onto.Unit.grams

If you need to use another unit, which is not defined yet in Veezoo, you can extend it.

Here is an example:

import: [
db.postgres.public.laptop
]

kb {

class Laptop {

...

integer RAM {
name.en: "RAM"
synonym.en: "memory"

// This refers to the unit defined inside the Laptop class
unit: kb.Laptop.Gigabyte

sql: "${laptop.ram}"
}


object Gigabyte {
// This is what gets displayed in charts and tables
// but is also used to understand your question
name: "GB"

// You can add synonyms to units, so Veezoo understands your questions better
synonym: [
"Gigabyte"
]

tag: KB_Unit

}

}

}

Now you can ask "Show me all Laptops with over 2GB of memory" or a more vague question like "How many gigabytes does a laptop have on average", and Veezoo will use the units available to understand your question.

Note, however, that currently Veezoo does not support automatic conversion between units, but we plan to support it in the future. For now, you would need to define separate numeric attributes with different units, if you would like to ask about it.

Here is an example:


number Revenue_in_USD {
name.en: "Revenue (USD)"

// Like this you can tell Veezoo to pick USD as the default Revenue,
// when unspecified in the question
synonym.en: "Revenue"

sql: "${TRANSACTON.revenue}"

unit: onto.Currency.USD
}

number Revenue_in_EUR {
name.en: "Revenue (EUR)"

// transform it here or point to a separate column
sql: "${TRANSACTON.revenue} * 1.1"

unit: onto.Currency.EUR
}