Impossible to use “Calculated columns” in “Custom metrics”, as they are not expanded. #18486
Replies: 4 comments
-
Thanks for posting! I'm not sure this is a bug, rather a feature request to expand calculated columns when referenced in other calculated columns. Something to keep in mind: The implementation could get nasty fairly quickly, as it would involve having to parse the expression, make assumptions about which elements are column references ( |
Beta Was this translation helpful? Give feedback.
-
You're right:
Meanwhile, the already implementable workaround is to manually expand the calculated columns in a custom metric definition — in other words, to base the metric on table's native columns only. |
Beta Was this translation helpful? Give feedback.
-
Another viable solution could be to make a virtual table where the expression is precalculated. This way you get to reference it similar to a regular column without that much trouble, as most modern DBs are able to effectively optimize subqueries so the performance hit should be negligible. |
Beta Was this translation helpful? Give feedback.
-
currently, Superset's "Calculated columns" is SQL snippet for specific database, instead of defined in BI-side expression (for instance: tableau function, power bi dax). It is not easy to know whether "Calculated columns" is a reference type, or a primitive type. |
Beta Was this translation helpful? Give feedback.
-
When creating a “calculated column”
foo
(defined, e.g. ascol1 + col2
), I can't reuse it in the “custom metric”bar
, as the generated SQL query usesfoo
literally (rather than expanding into itscol1 + col2
definition).This fails as
foo
doesn't actually exist as a column in the table I query.Expected results
I want to be able to now build charts using that custom metrics:
This means, running the following query:
Actual results
However, trying to use the custom metrics in Explore fails:
Indeed, the following query is executed:
(I.e. the
feelslike_offset
calculated column is not expanded to its definition:temperature_feelslike - temperature
.)Environment
(please complete the following information):
1.1.0
3.8.9
node -v
Checklist
Make sure to follow these steps before submitting your issue - thank you!
Beta Was this translation helpful? Give feedback.
All reactions