Subquery
Sometimes, multiple queries are required to transform the data in your data set, to find the answer you are looking for.
For example, you might want to calculate the percentage of your employees who are female. You will need to;
- Count total number of staff, and count the total number of those which are female.
- Divide the number of female staff, with the total number of employees and multiply this by 100.
You can see here that there are two stages to finding out the result, and each stage requires a query.
In Vizzly
The current way Vizzly supports this, is to return a subquery data set from the loadDataSetsCallback. This is a data set which is built by referencing a normal data set and providing a query.
{
id: string;
name: string;
subquery: {
// https://docs.vizzly.co/concepts/query
query: Query;
// Virtual fields only used to run the subquery against the base data set.
// https://docs.vizzly.co/concepts/virtualField
virtualFields: Array<VirtualField>;
};
// Virtual fields only to use on the data set, after the subquery has been ran.
// https://docs.vizzly.co/concepts/virtualField
virtualFields?: Array<VirtualField>;
};
Last updated on March 13, 2023