Python function for querying BI data

Query Business Intelligence data via Python

Operating mode

Cloud Suite

|

ON-PREMISES

Modules

Services & CRM

Budget & Phases

Purchases

Resource Planning

Business Intelligence

Created: 02.05.2025
Machine translated
Updated: 02.05.2025 | Python function from Vertec 6.8

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 None is, all available data in the time interval are taken into account.

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 ["Projekt", "Projektbearbeiter"] passed, then a result line results for each occurring combination of project and project user.

The following values can be passed:

  • For a simple dimension the class name (string)
  • For a dimension with Role, a tuple with the name of the dimension and the class name with dimension index (order), e.g.:

    ("Projektleiter", "Projektbearbeiter_1")
    ("Bearbeiter", "Projektbearbeiter_2")
  • For a time dimension, the string value "Month". If the measures include at least one cut-off date value, then the time dimension ("Month") in the dimensions, otherwise there is an error.
  • For a calculated dimension, a tuple consisting of the name of the calculated dimension, the class name, and an OCL expression: (<name>, <classname>, <OCL expression>).

    The OCL expression is evaluated on the result dimensions and leads to the actual result of the calculated dimension (e.g. for evaluation by customers of a project).

  • For a folder projection, a tuple consisting of the dimension name, the class name and the folder object whose subfolders represent the displayed dimensions: (<name>, <classname>, <ordner>).
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 None is specified, then start or end is open.

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 currency the key currency shall be used.

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.

  • dimension_tuple: Dimensionstupel. The dimensions can be defined using the method get_dimensions() If only one dimension is used, instead of the tuple, only the dimension object can be passed.
  • measure_name: Internal Name of the measure to be determined.
  • default_value: Optional. If the measure for the given dimension triplet has no value, the default value is 0 This parameter can be used to write a different value to the cell, e.g. None for a blank display.

To use this Python feature, a licensed Business Intelligence module is required, otherwise an error message appears.

Examples

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.

Simple example with one dimension and one measure
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)))
Example with Dimensions and Role
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)

 

Netherlands

United Kingdom