Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In some cases, it is useful to load a value from different data set rather than joining multiple data sets together (lookup value from different data set, similar to cross-referencing values from different data sets in the indicator formulas). In these cases functions lastValue() or firstValue() should be used. 

 
lastValue('DATASET_CODE.DATASET_CODE','L_ATTRIBUTE_CODE_OF_RETURNED_VALUE','[L_REFERENCED_COLUMN={' + value("L_CURRENT_COLUMN") + '}]') //will return the highest available value
firstValue('DATASET_CODE.DATASET_CODE','L_ATTRIBUTE_CODE_OF_RETURNED_VALUE','[L_REFERENCED_COLUMN={' + value("L_CURRENT_COLUMN") + '}]') //will return the lowest available value

 

Example:

In the current import settings, we import value Product code (column code L_PRODUCT_CODE), in the referenced data set, there is stored column Product name, which should be added to the new data set, product code is stored in the column Product ID (column code L_PRODUCT_ID) and column code of column Product Name is L_PRODUCT NAME. In this case following transformation script should be used:

firstValue('DATASET_CODE.DATASET_CODE','L_PRODUCT NAME','[L_PRODUCT_ID={' + value("L_PRODUCT_CODE") + '}]')

 

It is also possible to use more than one attribute for the filtering:

firstValue('DATASET_CODE.DATASET_CODE','L_ATTRIBUTE_CODE_OF_RETURNED_VALUE','[L_REFERENCED_COLUMN={' + value("L_CURRENT_COLUMN") + '}]'+
'[L_REFERENCED_COLUMN2={' + value("L_CURRENT_COLUMN2") + '}]'
) //will return the lowest available value