Column Visibility Problem #39321
Replies: 1 comment 12 replies
-
|
Hi @anwesha-smsrc! I'm Dosu and I’m helping the superset team. Superset doesn't have a built-in feature to automatically show/hide columns based on the current time period at the rendering layer. However, the best approach for your scenario is Jinja templating in your SQL query, which can dynamically control what columns appear without manual intervention. Using Jinja to conditionally include columns: You can use Jinja logic in a virtual dataset (SQL Lab query) or calculated column to check the current date and decide whether to include the bimonthly column. For example: SELECT
id,
four_monthly_value,
mat_value,
{% set current_month = modules.datetime.datetime.now().month %}
{% if current_month in [2, 4, 6, 8, 10, 12] %}
bimonthly_value
{% else %}
NULL AS bimonthly_value
{% endif %}
FROM your_tableThis way, during non-bimonthly periods the column returns If you use dashboard filters to drive the period, you can leverage the SELECT
id,
four_monthly_value,
mat_value,
{% if filter_values('period_type')|first == 'bimonthly' %}
bimonthly_value
{% else %}
NULL AS bimonthly_value
{% endif %}
FROM your_tableThe key insight is: keep the column in the query but return Additional options to consider:
Would you like me to look into specific Jinja templating examples or how to set up the date-based logic for your particular bimonthly schedule? To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The problem is there are three columns on the dashboard- for bimonthly, four monthly and MAT, MAT= annual basis, they want it in a certain way that for alternate bimonthly periods, the bimonthly data needs to be shown otherwise it should not appear on the Superset dashboard, now these columns are calculated field, in this scenario how can they alternatively appear? Is it possible in Superset without manual intervention? the column will be there anyways on the dashboard so if the sql query filters that specific column for that phase, it might show error on the dashboard. So is there any solution in this case?
@dosubot
Beta Was this translation helpful? Give feedback.
All reactions