Query Business Intelligence data via Python
Operating mode
Cloud Suite
|ON-PREMISES
Modules
Services & CRM
Budget & Phases
Purchases
Resource Planning
Business Intelligence
Starting with Vertec 6.8, the numbers from the Business Intelligence Module (BI) can also be used outside the BI views, for example in lists or reports. This allows even complex calculations to be shown without sacrificing performance, as the pre-calculated BI numbers are accessed.
For this there is the Python feature:
vtcapp.bigetdata(source, dimensions, measures, from, till, 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 |
dimensions |
Here the desired dimensions are specified as a list. In contrast to the BI interface, when specifying 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, till |
Date values, which designate the start or end point of the evaluation. Will |
currency |
Optional. Currency abbreviation or a currency object from Vertec. Specify the currency in which to output the data. Only necessary if currency-borne data (amount, rate) are output. There will be no |
The return value of bigetdata()
is a helper object with the following methods:
get_dimensions() |
Returns a list of all (found) dimensional tuples. |
get_value(dimension_tuple, measure_name, default_value=0) |
Returns the value of a measure for a dimension tuple.
|
To use this Python feature, a licensed Business Intelligence module is required, otherwise an error message appears.
The following examples can be run in the script editor. They will 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("Honorar: {}".format(result.get_value(project, "FeesExt"))) # alternativ kann man einen default Wert angeben, hier None print("Honorar: {}".format(result.get_value(project, "FeesExt", None)))
projects = vtcapp.currentlogin().evalocl("eigprojekte->select(aktiv)") dimensions = [ ("Projektleiter", "Projektbearbeiter_1"), ("Bearbeiter", "Projektbearbeiter_2") ] measures = ["MinutesInt"] result = vtcapp.bigetdata(projects, dimensions, measures, None, None) for key in result.get_dimensions(): text = "Projektleiter {}, Bearbeiter {}\nAufwand {}".format( key[0], key[1], result.get_value(key, "MinutesInt")) print(text)