Reputation: 2352
I am working with Apache Superset, and I am trying to run a calculation in one column based on the selection of a Filter Box.
The Filter Box has two values in a dropdown list: Yes and No.
If the user selects Yes, I want to do a calculation on one of the columns (multiply by 1000 for example). When the user selects No, I want to show the column as is without any calculations.
So far, I managed to filter the data based on the Filter Box value. But I am not sure how to use a CASE Statement based on the Filter Box value.
Upvotes: 1
Views: 3012
Reputation: 743
You may leverage jinja template processing, for that you need to create a virtual dataset using SQL Lab View.
Select if({{filter_values('dropdown_key_column')}} == 'Yes',column * 1000, column) from db.tblname
and using explore create visualisation.
For more understanding watch similar youtube videos: Superset Videos
Upvotes: 2