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

Analytical Need 

I would like to count all the products that are sold in Germany & Canada. When you select Germany and Canada in a typical Sisense filter, it will give you results for products that are sold either in Germany or in Canada but not sold only in both countries.

Modeling Challenge

In order to achieve this, you may need to perform a self join in the ElastiCube. If you have several combinations of attributes that you want analyze then you need to have many many tables which is not scalable or maintainable. 

The preferred way to do it is in the dashboard.

Solution

This is our example data:

Community_Admin_3-1634203254230.png

Image 1. The data

In the "country" filter we choose Germany & Canada and we want to get 2 (just id 1 & 2. They share Germany & Canada). 3 & 4 have just one of the countries and we don't want to count them.

Community_Admin_4-1634203254228.png

Image 2. Filter Selection

We present here 2 widget types that have the formula to calculate it but you can take the formula and apply it to other widget types.

  1. Pivot:
Community_Admin_5-1634203254135.png

Image 3. Pivot

We have 3 measures here:

# Records 

dupcount([id])

Give me the number of ids in the data, according to the filter selected

# Ids that have the Country filter values 

case when dupcount([id]) >= (count([Country]), all([id])) then 1 else 0 end

Here we check whether the number of ids is equal or higher than the amount of values selected in the filter (we add the all(id) because we don't want the rows to affect the count of Country). if so, then mark it as 1 otherwise mark it as zero.

Selected values in Country

(count([Country]), all([id])) 

Give me the number of values selected in the Country filter, regardless of the ids (in the pivot it automatically breaks it down by the rows and here we want to ignore it).

  1. Indicator: (this is the formula you should use for other widget types)
Community_Admin_6-1634203254213.png

Image 4. Indicator

# Ids that have the Country filter values:

sum([id] , case when dupcount([id]) >=(count([Country]), all([id])) then 1 else 0 end)

This is the same as the formula in the pivot, just with a multipass aggregation over all ids. This is because we want to sum up all the 1s for each id.

Download:

Dashboard

Ecdata

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

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

Product Feedback Forum:

Need additional support?:

Submit a Support Request

Sisense Privacy Policy