Sometimes, you may want to modify the query generated for a report based on the input parameters selected by end user. Different filter values may trigger different queries in such cases. To achieve this easily, dynamic query view feature has been added at metadata level in Helical Insight.

What is dynamic query?

Dynamic query essentially implies that the query is generated at runtime depending on the user inputs.This can be achieved by adding a dynamic logic/groovy script using which end user can use the filters, formdata expressions and groovy user session variables on runtime.

Adhoc report can be created using metadata with dynamic view where in report inputs will be taken from either metadata or from report or from both.

A report with dynamic view gives the better query performance in report along with runtime sql query execution.

Dynamic Query View in Metadata

Examples of Dynamic View:

Simple Dynamic View:

def q = "select * from \"travel_details\""
if(check("${filter}.label" , "booking")){
def f = findFilterByLabel("booking")
return q+" where \"booking_platform\" = $f.value "
}
else{
return q
}

Advanced Example with multiple condition and control statement

def q = "select * from \"travel_details\""
def reports_filter = ['booking','mode']
int wc = 0;
for(int i=0;i<filters.size();i++){
def item=filters[i]
if(reports_filter.contains(item.label)){
if(wc == 0){
q = q + " where ${item.column} ${item.condition} ${item.value}"
wc++
}
else{
q = q + " and ${item.column} ${item.condition} ${item.value}"
}
}
}
return q

Note: It is mandatory for the groovy code in the dynamic query to have a return type.

Available Configurations:

Below are the available filter and global expressions using which you can create the dynamic view:

    1. FormData:

It returns the information about the report, metadata, columns, filters etc. used in the adhoc report.


Expression

formData
Drescrption formData returns adhoc report formdata with all details of report ,metadata,tables.colums,filters info etc. used in adhoc report.
For Ex. return formData
In adhoc report ,based on the created report it will return the respective formdata.
It returns formdata data in json format.

Note : formdata specific information can be retrieved by (.) dot notation.

Example : return formData.location
Output :1463377807724/1463377836985/1591703058466
This way end user can utilize required formdata information.

This way end user can utilize required formdata information.

More details present in the blog FormData

    1. Filters:

Dynamic queries allow the report level filters to be used in the view to generate the query based on those filters.

Filters can be accessed by using the ${filter} notation.

Filter has many properties like filter label,mode,condition,value etc based on which user can create dynamic view based upon the requirement and the logic.

Below mentioned image shows the output of the different expressions:

Dynamic Query View in Metadata

Dynamic Query View in Metadata


Expression

Filters
Drescrption filter returns the filter component including all filters used in adhoc report along with its filter information.
With (.) dot notation end user can fetch required information from filters.
For Ex. return filters
Output:
[
{
	fullyQualifiedColumn="FilterDynamicView"."booking_platform",
	column="booking_platform",
	condition==,
	isCustomCondition=false,
	dataType=java.lang.String,
	custom=null,
	value='Agent',
	values=[Agent],
	isCustomValue=false,
	id=0,
	label=booking_platform,
	mode=auto
}

,
{
	fullyQualifiedColumn="FilterDynamicView"."destination",
	column="destination",
	condition==,
	isCustomCondition=false,
	dataType=java.lang.String,
	custom=null,
	value='Agra',
	values=[Agra],
	isCustomValue=false,
	id=1,
	label=destination,
	mode=auto
}
]

It returns filters component with all filter information.

Note : filters specific information can be retrieved by (.) dot notation.

Example :return filters.fullyQualifiedColumn
Output:[“FilterDynamicView”.”booking_platform”, “FilterDynamicView”.”destination”]

This way end user can utilize required filters information.

For details on the various filter expressions available refer to this blog Filter Expressions

    1. Logical

User can use logical expression in dynamic view which are used to check the conditions like check for filters, has filters etc.

Below are some logical expressions for dynamic view:

      1. check(“${filter}.label” ,”value”)

This expression is used to compare the filter label to a user defined string.


Expression

check(“${filter}.label” ,”value”)
Drescrption This function will return true when there is any filter withprovided filter label as value.The check function works with all other filter properties such as column, value, values, condition etc.We can use check function with if condition to check whether any filter exists or not.
For Ex.
if( check("${filter}.label" ,"booking_platform"))
{
return " ${filter}.label"
}

Output : booking_platform,destination

If filter label exists then will get output.In case filter label does not match then end user will get error or user can handle condition using else statement.

      1. hasFilters()

This expression is used to check whether the report has any filters defined.


Expression

hasFilters()
Drescrption This function will return true if there is any filters available otherwise false.
Can be used to whether any filters exists/not during runtime.
We can use hasFilters function with if condition to check whether any filter exists or not.
For Ex.
if(hasFilters())
{
return " ${filter}.values"
}

Output : ‘Agent’,’Agra’

If filter label exists then will get output.In case of no filters end user will get error or user can handle condition using else statement.

    1.  
    2. GroovyUserSession

End user can use groovy user session variables for writing dynamic view.Using it end user can get all user,role,profile,organization information based on which we can write the logic inside dynamic view.

Below is the sample example of dynamic view using GroovyUserSession

import com.helicalinsight.efw.utility.GroovyUsersSession;
def userRole = GroovyUsersSession.getValue('${user}.name');
if(userRole.contains('test')){
return "select * from \"meeting_details\""
}
    1. sqlContext

By using sqlContext functions using (.) dot notation end user can get required information. The sqlContext is a groovy object that is available by default inside the script. You can use it as sqlContext. The sqlContext has some useful method that can help you to dive deep into the formdata and the metadata from sqlContext methods.

Below is the list of functions that can be used during writing script:

SR. No: Function Name: Return Type
1 sqlContext.getDatabaseName() String
2 sqlContext.getDerivedTableColumn() List<String>
3 sqlContext.getDerivedTableNames() List
4 sqlContext.getDriverClassName() String
5 sqlContext.getFormData() JSONObject
6 sqlContext.getHibernateDialect() Dialect
7 sqlContext.getMetadata() Metadata
8 sqlContext.getOpenQuote() String
9 sqlContext.getQueryLimit() String
10 sqlContext.getQueryOffset() String
11 sqlContext.getReferenceFile() String
12 sqlContext.getReferenceFile() List
13 sqlContext.getStandardSqlFunction() SqlFuntion
14 sqlContext.getTableName(String) String
15 sqlContext.getTables() List
16 sqlContext.isApplyAggregation() boolean
17 sqlContext.isApplyGroupBy() boolean
18 sqlContext.isApplyHaving() boolean
19 sqlContext.isApplyOrderBy() boolean
20 sqlContext.isApplyWhere() boolean
21 sqlContext.isDistinctResults() boolean
22 sqlContext.isLimitRequested() boolean
23 sqlContext.quotes(String) String
    1. addQuotes(string

This function can be used to add single quotes to the provided string.


Expression

addQuotes(string)
Drescrption For Ex. return addQuotes(filter)
Output :
'
[fullyQualifiedColumn:"FilterDynamicView"."booking_platform",
"FilterDynamicView"."destination",
condition:=,
=,
isCustomCondition:false,
false,
dataType:java.lang.String,
java.lang.String,
custom:null,
null,
values:'Agent',
'Agra',
isCustomValue:false,
false,
id:0,
1,
label:booking_platform,
destination,
mode:auto,
auto,
column:"booking_platform",
"destination"]'

It will return filter array as output because we have passed filter as string.

    1. getFilterArrayByLabels([“labelArray”])

This utility gives the filter components based on the provided filter label array as parameter.


Expression

getFilterArrayByLabels([“labelArray”])
Drescrption For Ex. filtersbyLabels=getFilterArrayByLabels([“booking_platform”,”destination”])
return “$filtersbyLabels”
Output :
[[fullyQualifiedColumn:"FilterDynamicView"."booking_platform",
column:"booking_platform",
condition:=,
isCustomCondition:false,
dataType:java.lang.String,
custom:null,
value:'Agent',
values:[Agent],
isCustomValue:false,
id:0,
label:booking_platform,
mode:auto],
[fullyQualifiedColumn:"FilterDynamicView"."destination",column:"destination",condition:=,isCustomCondition:false,
dataType:java.lang.String,custom:null,value:'Agra',values:[Agra],
isCustomValue:false,
id:1,
label:destination,
mode:auto]]

It will return filter array as output because we have passed filter as string.

    1. findFilterByLabel(“label”)

This utility gives the filter component based on the provided filter label as parameter.


Expression

findFilterByLabel(“label”)
Drescrption For Ex. bookingFilter= findFilterByLabel(“booking_platform”)
bookingCondition=bookingFilter .condition
return “$bookingCondition”
Here bookingFilter is a groovy object that will hold the filter component if a filter with label booking_platform is found.
bookingFilter and its properties can be used with dot(.) notation.
bookingFilter .condition will return the condition of that filter or we can use any other filter attribute
Output : =
It returns filter condition as output when filter label matches.
    1. findFilter([key:value,key:value])

Expression

findFilter([key:value,key:value])
Drescrption Using this groovy map utillity end user will get the filter component based on the provided json key and value
Syntax : findFilter(criteriaUsingGroovyMap)
Note : The usage of groovy map as criteria.

For Ex. getFilter= findFilter([condition:”=”,id:1])
return “$getFilter”

Here getFilter is a groovy object that will hold the filter component if a filter with condition = and id as 1 is found

Output:

[fullyQualifiedColumn:"FilterDynamicView"."destination",
column:"destination",
condition:=,
isCustomCondition:false,
dataType:java.lang.String,
custom:null,
value:'Agra',
values:[Agra],
isCustomValue:false,
id:1,
label:destination,
mode:auto]

It returns filter component as output when filter with provided conditions matches.

    1. findFilter(‘{“key”:”value”}’)

Expression

findFilter(‘{“key”:”value”}’)
Drescrption Using this json string utillity end user will get the filter component based on the provided json key and value.
Syntax : findFilter(jsonFindParameters)
Note : The usage of json criteria as a string parameter

Here json key can be filter attributes like label,value,condition,mode etc.
For Ex. bookingFilter=findFilter(‘{“label”:”booking_platform”}’)
bookingCondition=bookingFilter .condition
return “$bookingCondition”

Here bookingFilter is a groovy object that will hold the filter component if a filter with label booking_platform is found.
bookingFilter and its properties can be used with dot(.) notation.
bookingFilter .condition will return the condition of that filter or we can use any other filter attribute
Output : =

It returns filter condition as output when filter label matches.

    1. filters.size()

This function returns the number of filter count present in report. To check the filter size we can use this function. It return 0 when no filters are available.


Expression

filters.size()
Drescrption For Ex.
if( filters.size()>0)
{
return "${filter}.column"
}

Output : “booking_platform”,”destination”

It returns filter column as output when filter size is greater than 0.

For further assistance, kindly contact us on support@helicalinsight.com or post your queries at Helical Forum

Helical Insight’s self-service capabilities is one to reckon with. It allows you to simply drag and drop columns, add filters, apply aggregate functions if required, and create reports and dashboards on the fly. For advanced users, the self-service component has ability to add javascript, HTML, HTML5, CSS, CSS3 and AJAX. These customizations allow you to create dynamic reports and dashboards. You can also add new charts inside the self-service component, add new kind of aggregate functions and customize it using our APIs.
Helical Insight’s self-service capabilities is one to reckon with. It allows you to simply drag and drop columns, add filters, apply aggregate functions if required, and create reports and dashboards on the fly. For advanced users, the self-service component has ability to add javascript, HTML, HTML5, CSS, CSS3 and AJAX. These customizations allow you to create dynamic reports and dashboards. You can also add new charts inside the self-service component, add new kind of aggregate functions and customize it using our APIs.
Helical Insight, via simple browser based interface of Canned Reporting module, also allows to create pixel perfect printer friendly document kind of reports also like Invoice, P&L Statement, Balance sheet etc.
Helical Insight, via simple browser based interface of Canned Reporting module, also allows to create pixel perfect printer friendly document kind of reports also like Invoice, P&L Statement, Balance sheet etc.
If you have a product, built on any platform like Dot Net or Java or PHP or Ruby, you can easily embed Helical Insight within it using iFrames or webservices, for quick value add through instant visualization of data.
If you have a product, built on any platform like Dot Net or Java or PHP or Ruby, you can easily embed Helical Insight within it using iFrames or webservices, for quick value add through instant visualization of data.
Being a 100% browser-based BI tool, you can connect with your database and analyse across any location and device. There is no need to download or install heavy memory-consuming developer tools – All you need is a Browser application! We are battle-tested on most of the commonly used browsers.
Being a 100% browser-based BI tool, you can connect with your database and analyse across any location and device. There is no need to download or install heavy memory-consuming developer tools – All you need is a Browser application! We are battle-tested on most of the commonly used browsers.
We have organization level security where the Superadmin can create, delete and modify roles. Dashboards and reports can be added to that organization. This ensures multitenancy.
We have organization level security where the Superadmin can create, delete and modify roles. Dashboards and reports can be added to that organization. This ensures multitenancy.
We have organization level security where the Superadmin can create, delete and modify roles. Dashboards and reports can be added to that organization. This ensures multitenancy.
We have organization level security where the Superadmin can create, delete and modify roles. Dashboards and reports can be added to that organization. This ensures multitenancy.
A first-of-its-kind Open-Source BI framework, Helical Insight is completely API-driven. This allows you to add functionalities, including but not limited to adding a new exporting type, new datasource type, core functionality expansion, new charting in adhoc etc., at any place whenever you wish, using your own in-house developers.
A first-of-its-kind Open-Source BI framework, Helical Insight is completely API-driven. This allows you to add functionalities, including but not limited to adding a new exporting type, new datasource type, core functionality expansion, new charting in adhoc etc., at any place whenever you wish, using your own in-house developers.
It handles huge volumes of data effectively. Caching, Pagination, Load-Balancing and In-Memory not only provides you with amazing experience, but also and does not burden the database server more than required. Further effective use of computing power gives best performance and complex calculations even on the big data even with smaller machines for your personal use. Filtering, Sorting, Cube Analysis, Inter Panel Communication on the dashboards all at lightning speed. Thereby, making best open-source Business Intelligence solution in the market.
It handles huge volumes of data effectively. Caching, Pagination, Load-Balancing and In-Memory not only provides you with amazing experience, but also and does not burden the database server more than required. Further effective use of computing power gives best performance and complex calculations even on the big data even with smaller machines for your personal use. Filtering, Sorting, Cube Analysis, Inter Panel Communication on the dashboards all at lightning speed. Thereby, making best open-source Business Intelligence solution in the market.
With advance NLP algorithm, business users simply ask questions like, “show me sales of last quarter”, “average monthly sales of my products”. Let the application give the power to users without knowledge of query language or underlying data architecture
With advance NLP algorithm, business users simply ask questions like, “show me sales of last quarter”, “average monthly sales of my products”. Let the application give the power to users without knowledge of query language or underlying data architecture
Our application is compatible with almost all databases, be it RDBMS, or columnar database, or even flat files like spreadsheets or csv files. You can even connect to your own custom database via JDBC connection. Further, our database connection can be switched dynamically based on logged in users or its organization or other parameters. So, all your clients can use the same reports and dashboards without worrying about any data security breech.
Our application is compatible with almost all databases, be it RDBMS, or columnar database, or even flat files like spreadsheets or csv files. You can even connect to your own custom database via JDBC connection. Further, our database connection can be switched dynamically based on logged in users or its organization or other parameters. So, all your clients can use the same reports and dashboards without worrying about any data security breech.
Our application can be installed on an in-house server where you have full control of your data and its security. Or on cloud where it is accessible to larger audience without overheads and maintenance of the servers. One solution that works for all.
Our application can be installed on an in-house server where you have full control of your data and its security. Or on cloud where it is accessible to larger audience without overheads and maintenance of the servers. One solution that works for all.
Different companies have different business processes that the existing BI tools do not encompass. Helical Insight permits you to design your own workflows and specify what functional module of BI gets triggered
Different companies have different business processes that the existing BI tools do not encompass. Helical Insight permits you to design your own workflows and specify what functional module of BI gets triggered