Versions Compared

Key

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

With effect from 2022-03-24 With effect from the pi.2022-03-31 dashboard release:

Sub-query will enable users to introduce charts as filter values, this means that charts are run as sub-queries which will help build the data of the main chart.

What is Sub-query:

In the example below:

  • We have a chart called ‘Sales Overview’

  • This chart has been filtered using another chart called ‘Cities with Outstanding Sales’

This results in the ‘Sales Overview’ chart being filtered to only show data related to cities with outstanding sales.

This works by running the SQL query of the sub-chart, ‘Cities with Outstanding Sales’, and using the values from this chart to populate the filter for the ‘Sales Overview’ chart.

new screenshot

...

Please refer to this page to see a walkthrough of a sub-query filter.

How does Sub-query work:

  • when using an in/not in operator - the first column of the data from the sub-chart is used (multiple values, as described on the tooltip in the screenshot)

  • top/bottom operator - sub-query charts are not allowed, so you don’t have when using a top/ bottom operator, the option to put select a chart hereto filter on will not be available

  • single value operator e.g. Like - the first data point (first row of the first column) is used as the filter value

 

When clicking on the drop down to pick the value for a filter, not only data can be used, charts are now also allowed to be selected as belowAfter selecting what you want to filter on and the operator you want to use you will then be able to select from data or a chart when picking the value to filter on. The type of charts allowed to be used as sub-query are similar to the merged chart/table

...

options that you can select from when using merged charts/ tables. If a chart can be used as a sub-chart of a merged chart or table, it can be used as sub-query

...

. This means that

  • lines, bars, tables are allowed

  • pies, special shapes, maps, merged charts/tables and so on are not allowed

...

 

...

  • can not be used

The ‘Type to filter’ screen has now been split into two sections - Data and Charts. The Data screen is used in the same way as it was previously (please see this page for more information) and there is now an additional ‘Charts’ screen.

The screenshot below shows the chart types that can be selected from the ‘Charts’ screen. If a chart type can not be used in a sub-query it will not be displayed on the' Charts' screen.

...

Why use sub-query

...

By using Sub-query mainly enables the following capabilities, you will be able to:

  • it allows use sub-chart data from another data connection, e.g. in the following example.

    • chart 1 is from a Sales data connection

    • chart 2 is from a HR data connection

    • chart 1 can have a filter, and the value is be filtered using chart 2

    • this means you can could view the sales related to employees who take a lot of holidays

  • it allows use sub-chart data from another chart, which is built with complex sql query structure

Performance with sub-query:

Since sub-query charts are building charts to be used by other charts, the time it takes to display a chart will be the total time it takes to build all the charts used. You can see a breakdown of these times by clicking Chart Tools>Chart Information and selecting the ‘Debug’ tab - add screenshot..

...

In this example, the total time to build all charts is 586ms. This includes the 352ms taken to build the sub-query chart - you can see this information at the bottom of the debug page on the main chart.

...

Info

To reduce the length of time taken to draw your chart, try to avoid using lots of sub-query references in your charts.

...

Potential problems:

  • Cycle referencing: If Chart 1 uses Chart 2, Chart 2 uses Chart 3, Chart 3 uses either Chart 1 or Chart 2 as sub-query, the system shows an error

  • Sub-charts are changed: If a sub-chart is edited afterwards, you may get unexpected results on the main chart while the main chart is not likely to be broken, because the main chart simply just picks the first column or first data point of the sub-charts, it doesn’t care how the sub-charts are configured

  • Sub-charts not having data: again, the main chart is not likely to display data since there isn’t anything relevant

Elementor macro
rowWidth100
title0h8n66
content[{"id":"bw6mx","order":1662462304798,"background":{"source":"color","value":"#ffffff","id":""},"backgroundOverlay":{"isActive":false,"color":"#000000","opacity":0.5},"rows":[{"id":"mach3k","order":1662462304798,"type":"one","columns":[{"id":"5v2xhk","order":1,"alignment":{"vertical":"center","horizontal":"center"},"macro":{"id":"pagedivider","dividerColor":"#8d135bff","text":"Related Topics","fontSize":24,"textAlignment":"center","dividerWidth":100,"dividerWeight":3,"dividerType":"text-only","dividerIcon":"atlaskit/StarFilledIcon","textColor":"#8d135bff","iconColor":"#000","labelPosition":"middle","emojiEnabled":"false","emoji":{"id":"smile","name":"Smiling Face with Open Mouth and Smiling Eyes","short_names":["smile"],"colons":":smile:","emoticons":["C:","c:",":D",":-D"],"unified":"1f604","skin":null,"native":"😄"}}},{"id":"2p7yz","order":2,"alignment":{"vertical":"center","horizontal":"center"},"macro":{}},{"id":"gd4dr","order":3,"alignment":{"vertical":"center","horizontal":"center"},"macro":{}},{"id":"4cq6v","order":4,"alignment":{"vertical":"center","horizontal":"center"},"macro":{}}]},{"id":"xcgo7b","order":1662462374011,"type":"one","columns":[{"id":"ayxccs","order":1,"alignment":{"vertical":"center","horizontal":"center"},"macro":{"id":"pages","type":"list","layout":"four","loadType":"manual","parentPage":"","manualPages":[{"id":"b2a3wl","position":0,"contentId":"1100939294"}],"labels":[],"spaces":[],"contributors":[],"numberOfItems":8,"pagination":"infinite"}},{"id":"uz10ba","order":2,"alignment":{"vertical":"center","horizontal":"center"},"macro":{}},{"id":"nrke9n","order":3,"alignment":{"vertical":"center","horizontal":"center"},"macro":{}},{"id":"foo6pq","order":4,"alignment":{"vertical":"center","horizontal":"center"},"macro":{}}]}]}]