How to query BI data using Python
Operating mode
Cloud Suite
|ON-PREMISES
Modules
Services & CRM
Budget & Phases
Purchases
Resource Planning
Business Intelligence
Starting with Vertec 6.8, you can now use the Business Intelligence Module (BI) figures outside the BI views, for example in lists or reports. With this, even complex calculations can be shown without sacrificing performance, as the pre-calculated BI figures are accessed.
For this, there is a new Python function:
vtcapp.bigetdata(source, dimensions, measures, from, to, currency=None)
source |
The source can be a single object or a list of objects for which the BI data is to be read. In this case, only the values belonging to these objects are taken into account. If source is |
dimensions |
Here, the desired dimensions are specified as a list. In contrast to the BI interface, if you specify several dimensions, the values are grouped according to them. For example, if The following values can be passed:
|
measures |
A list of BI measures. The list can be passed either as a string list with the names of the measures, or as a list of measure objects. |
from, to |
Date values, which designate the start or end point of the evaluation. If |
currency |
Optional. Currency abbreviation or a currency object from Vertec. Indicates the currency in which the data should be output. Only necessary if currency data (amount, rate) are output. If no |
The return value of bigetdata()
is an auxiliary object with the following methods:
get_dimensions() |
Returns a list of all (found) dimension tuples. |
get_value(dimension_tuple, measure_name, default_value=0) |
Returns the value of a measure for a dimension tuple.
|
To use this Python function, a licensed Business Intelligence module is required; otherwise, an error message appears.
The following examples can be run in the Script Editor. They output the result in the output window and should help you understand the mechanism.
projects = vtcapp.currentlogin().evalocl("eigprojekte->select(aktiv)") result = vtcapp.bigetdata(projects, ["Projekt"], ["FeesExt"], None, None) for project in projects: # standardmässig "0", wenn es für eine Kennzahl keinen Wert gibt print("Fee: {}".format(result.get_value(project, "FeesExt"))) # alternatively, you can specify a default value, here None print("Fee: {}".format(result.get_value(project, "FeesExt", None)))
projects = vtcapp.currentlogin().evalocl("eigprojekte->select(aktiv)") dimensions = [ ("Project manager", "Projektbearbeiter_1"), ("User", "Projektbearbeiter_2") ] measures = ["MinutesInt"] result = vtcapp.bigetdata(projects, dimensions, measures, None, None) for key in result.get_dimensions(): text = "Project manager {}, User {}\nHours {}".format( key[0], key[1], result.get_value(key, "MinutesInt")) print(text)