Professional Documents
Culture Documents
Spagobi Server WhatIf
Spagobi Server WhatIf
Giulio Gavardi
2016/03/30 12:12
spagobi_server - SpagoBI WhatIf Engine
Table of Contents
Document Template ................................................................................................................................................................... 3
Schema Structure for the Whatif scenario ................................................................................................................................. 4
Writeback ................................................................................................................................................................................... 6
SQL server ................................................................................................................................................................................. 8
XMLA Connection .................................................................................................................................................................... 8
Use analytical driver into schema definition .............................................................................................................................. 9
The SpagoBIWhatIfEngine is the brand new SpagoBI OLAP engine with writeback capabilities, based on the popular Mondrian
OLAP engine.
• Document Template
• Schema Structure for the Whatif scenario
• Writeback
• SQL server
• XMLA Connection
• Use analytical driver into schema definition
Document Template
The template is very similar to the one of Jpivot http://wiki.spagobi.org/xwiki/bin/view/spagobi_server/JPivot
• <cube reference="SCHEMA"/>
The schema for the cube. The value of the attribute reference is the label of the schema saved in the Schema catalogue
• <MDXMondrianQuery>
The MDXMondrianQuery section contains the original MDX query (the one edited via the wizard)
• <MDXquery>
The MDX section contains a variation of the original MDX query, as used by SpagoBI Engine. This version includes
parameters (if any).
• <SCENARIO>
This tag should be used when the user want to perform what if analysis.
The attributes and subtags of the tag are:
° name: the name of the scenario. It’s only a label and it’s not used by the engine..
° editCube: the name of the table that contains contains the edited values (see the structure of the schema section)
° <MEASURE>MEASURE NAME </MEASURE>: there could be 0 or n tag measure. They are the names of the
editable measures. If no tag measure is defined than all the measures are editable.
° <VARIABLE name="var" value="5"/>: variables that can be used in the editing formulas. The
• contain all the foreign key to the dimension (all the ones visible in the cube)
• contain all the editable measures
• contain a new numeric column that is a foreign key referencing the version table.
Here an example where the cube is sales_fact_1998 and the new table is sales_fact_1998_virtual
sales_fact_1998_virtual table should be initialized with the same data contained in sales_fact_1998 plus 0 as version; the
wbversion table should be initialized with one record with wbversion = 0 and a name and a description for "Original values".
(Sales Count Original is the name of a measure in the Sales cube). This is a trick for the not editable measures.
This type of measure lives only in the DWH cube and not in the editable cube. This cause that the engine doesn’t
know how to give a value for these measures for the different values of the Version dimension (remember that
only the editable cube has the Version dimension). The calculated field solve this problem propagating the same
version of the not editable (and versionable) measure for all the version.
Now all the MDX queries should be performed in the virtual cube.
Writeback
The SpagoBIWhatIfEngine has write-back capabilities, i.e. you can edit the value of a cell and observe the results.
Keep in mind that changes are stored in memory: if you want to persist modifications into the database, you have to click on
When modifying a cell, since this cell may contain an aggregate value on several dimensional members, the new value must
be divided into all the underlying members, untill leaves are reached.
The What-If engine, at the moment (SpagoBI 5.0.0), supports only one propagation algorithm, that does not modify the
weight of sibling children members. When a cell with X value is modified and Y value is set as new value, this formula is
applied to the children cells:
This formula doesn't make sense when X is 0 or it doen't even exist: this is the reason why you cannot modify cell with no
value or with zero-value.
Let's look at an example: we (nearly) double the value for Drink and children cells are updated keeping the same ratio
between them:
You can modify a cell and enter a new value or a formula using a particular language that is described below.
You can also refer to members that are not included in the tuple represented by the cell being modified: let's see some
examples: suppose the cell refers to the following tuple:
[Measures].[ Store Sales], [Product].[Food].[ Deli], [Version].[0], [Region].[Mexico Central], [Customers].[All Customers],
[Customers].[All Customers]
with just
Product.Eggs
[Measures].[ Unit Sales], [Product].[Food].[ Eggs], [Version].[0], [Region].[Mexico Central], [Customers].[All Customers],
[Customers].[All Customers]
with:
Product.Eggs;Measures.Unit Sales
When referring to external members (members that are not included in the tuple of the cell), remember that you can get only
refer to members on the same level of the internal ones.
The syntax is
<dimension's name>.<member's name> or [<dimension's name>].[<member's name>]
or, in case you are using another hierarchy
<dimension's name>.<hierarchy's name>.<member's name> or [<dimension's name>].[<hierarchy's name>].[<member's
name>]
and you can concatenate different members with ";".
You can also refer to members that are on the same level but they are not sibling members: suppose that, for example, the
cell's tuple is
[Measures].[Store Sales], [Product].[ Food].[ Deli], [Version].[0], [Region].[Mexico Central], [Customers].[All Customers],
[Customers].[All Customers]
[Measures].[Store Sales], [Product].[ Drink].[ Alcoholic Beverages], [Version].[0], [Region].[Mexico Central], [Customers].
[All Customers], [Customers].[All Customers]
just with:
[Product].[Drink.Alcoholic Beverages]
[Measures].[Store Sales], [Product].[ Food].[ Deli].[ Meat], [Version].[0], [Region].[Mexico Central], [Customers].[All
Customers], [Customers].[All Customers]
to
[Measures].[Store Sales], [Product].[ Drink].[ Alcoholic Beverages].[ Beer and Wine], [Version].[0], [Region].[Mexico
Central], [Customers].[All Customers], [Customers].[All Customers]
Note that the last part of the expression is the portion of the path to the target member that differs from the path of the cell's
member.
Variables
When modifying an OLAP analysis, you normally are operating in a scenario that might have variables (the inflation rate, for
example, or the number of employees) that you can define and use when modifying a cell's value.
The definition of the scenario is provided within the template of the document:
In case the variable is an integer or double value, is it considered just as a static number; instead, if it is a string, it is
considered to be the reference to one or more dimensional members. This reference is intented to be relative to the cell being
modified and it must be specified with the syntax described above, for example:
Aliases
A part from variables, you can also use aliases when editing an expression.
The definition of the aliases is contained into the document's template:
<ALIASES>
<DIMENSION name="Product" alias="P"/>
<HIERARCHY name="Time Weekly" alias="W"/>
<ALIAS name="Product.Eggs" alias="Eggs"/>
</ALIASES>
As shown in the above example, an alias can refer to:
It is possible also to refer to a hierarchy in one dimension with a single alias: in the following example, TW is resolved as
Time.Time Weekly:
<ALIASES>
<DIMENSION name="Time.Time Weekly" alias="TW"/>
</ALIASES> the version.
Now all the MDX queries should be performed in the virtual cube.
SQL server
If your datasource is the RDBM SQL Server, in the JDBC Url you should add the prefix jdbc. to the property databaseName.
So the URL should be something like
jdbc:sqlserver://USER\MSSQLSERVER2; jdbc.databaseName =TEST_DWH
XMLA Connection
If you are connecting to a XMLA server you should add the end point of the server into the document template.
Technically specking you should add the tag <xmlaserver>. The possible children are the the url of the server and the list of
properties required for the connection.
Example
Example