Dynamically change the filter with additional functions based on the selected value

Hello,

So basically I want to dynamically change the filter value which gets passed based on the filter value selected.

Can I change the SQL based on my filter value (i.e., dynamically change the SQL)? If the filter value is ‘Cash’, I want to display only booking_platform; otherwise, I would like to concatenate the filter value (mode_of_payment) with booking_platform.

Could you provide a working example of a dynamic query for this?

I am using Open source BI Helical Insight version 5.2.3 enterprise version.

Thanks,
Snow.

Hello Snow,

Please use the dynamic query option at the metadata view level. Something like below can be put there.

image

if (hasFilters()) {
    mode_of_payment = findFilterByLabel("mode_of_payment")
   mode_of_paymentValue = mode_of_payment.value.replace('_all_', "'_all_'").replace(")" ,"")
   
   
	if(!mode_of_paymentValue.contains("Cash")){
    return "select mode_of_payment, CONCAT(" + mode_of_paymentValue + ", booking_platform) as booking_platform from travel_details"
	}else{
	return "select mode_of_payment, booking_platform from travel_details"
	}
} else {
    return "select mode_of_payment, booking_platform from travel_details"
}

image

image

Thank You,
Helical Insight.