In this post, we are going to show you how to use multiple PALO functions in the macro to successfully add element in the dimension. For this purpose we are going to use the Biker database and elements will be added to the Product dimension. Have in mind that example is for the users who use the cloud instance of jedox.

First we need to establish connection with the OLAP.

$host = $_JEDOX[‘OLAP_HOST’];
$port = $_JEDOX[‘OLAP_PORT’];
$conn = palo_init($host, $port, $_JEDOX[‘OLAP_SESSION_ID’]);

 

Then we need to formulate Palo.EADD function. this function consists of the following parameters.

PALO.EADD(Server/Database, Dimension, Type, Element, Parent Element, Weight, Clear, Error suppr.)

Possible values for Clear are 0 (or FALSE), 1 (or TRUE) and 2

  • 0: Removes no elements of the dimension before importing
  • 1: Removes all elements of the existing dimension before importing
  • 2: Removes all existing elements of the C-dimension before importing. Basic elements are not deleted.

More about this and other functions can be found here.

When these are combined code should look something like this:

 

 

function _btnAddElement_Click ()
{

$host = $_JEDOX[‘OLAP_HOST’];
$port = $_JEDOX[‘OLAP_PORT’];
$conn = palo_init($host, $port, $_JEDOX[‘OLAP_SESSION_ID’]);

$Database = “Biker”;

$Element = activeworkbook()->names->item(‘element’)->value;
$Dimension = activeworkbook()->names->item(‘dimension’)->value;

$Parent = activeworkbook()->names->item(‘parent’)->value;

palo_eadd($conn,$Database,$Dimension,’N’,$Element,$Parent,1,FALSE);
palo_disconnect($conn);
}

add element

in addition to this code, there is a possibility as well to add attributes to the new element or even to set a value in some of the cubes.

For adding the attribute this code needs to be added:

application()-> palo_setdata($AttributeCode,true,$Connection,$Cube,”Code”,$Element);

For adding data/value this code needs to be added (example splashing 1 on all base elements):

application()-> palo_setdata(“!1″,true,$Connection,”Cube Name”,$dimension1,$dimension2,$Element);

where $Connection will be “localhost/Biker” for example

 

With 2021 versions action buttons are giving the same opportunity without even using a macro

add element via action button

More about action buttons can be found here.

 

Also, examples of the adding elements can be downloaded here.

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!