cancel
Showing results for 
Search instead for 
Did you mean: 
Community_Admin
Community Team Member
Community Team Member

Purpose:

To create a product aggregation in Sisense (multiplies all values together, similar to the way a sum function adds all values together).

 

Situation:

A financial use case has a table with relative daily gains/losses for certain securities (think stocks; if yesterday it closed at $100 and today it closed at $101, then there was a 1% gain today).  The goal is to calculate the % change over any given timeframe from the start to the end or in other words, multiply each day’s value (+ 1), or in Excel land Product(1+value).

Approach:

There is no product function in Sisense (it is not a common BI function), so we needed to break down the function into its fundamental parts.  We found this site which outlines how to do just that with some other functions that Sisense has. The end result, which assumes we have all positive values (applicable for this use case) looks like this in SQL:

Community_Admin_0-1634209558417.png

Note: the base of the log must match the base of the exponential

Resolution:

  • Start with the table shown below.  The XLE column is the relative gain or loss for that day and the XLENorm = XLE + 1 (now they will all be positive).  The idea here is to take the product or in other words multiply all values form the XLENorm field together to get an aggregate relative value over any given date range.

Community_Admin_1-1634209558452.png

  1. Create a new widget with the following function.

Community_Admin_2-1634209558416.png

  1. This is similar to what was shown above, but the LN() function takes an aggregation.  Therefore we make the input for LN the sum of XLENorm, and in the SUM() we add a multi-pass by date.  It will roll up to whatever you like however I suggest duplicating the Date field so you can drill all the way down to the dates as well (requirement of multi-pass).
  2. Finished product:

Community_Admin_3-1634209558464.png

Notes & Insight:

  • This could have several potential applications for financial or other use cases (compounding interest rates, etc.)
  • As noted before this particular calculation assumes a positive value which was fine for our purposes.  As outlined in the document there are some other more encompassing formulas which will work for zero, null and negative values.  These should be possible in Sisense but would require some nested conditional statements or perhaps some smart use of filters, absolute values, counts of negatives (aka the product of an even number of non-null or zero values is positive, and the product of an odd number of non-null or zero values is negative) and possible Boolean algebra
  • A product function is not available in most other BI tools, nor as a standalone function in SQL

 

Version history
Last update:
‎10-14-2021 04:07 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Need additional support?:

Community Support Request