Dear colleagues,
I'm in need of finishing a dashboard with the new databricks dashboard structure, released somewhat recently. On it, I'll have some calculations which need to be percentages over certain partitions, such as `input_amount_percentage_per_input_key_type`.
I've been having a lot of trouble to make work the following query:
select
conciliation_status,
input_key_type,
input_key,
acquirer,
input_date,
first_effect_date,
sum(input_amount) as input_amount,
sum(1) as event_amount,
sum(input_amount) / sum(sum(input_amount)) over (partition by input_key_type) as input_amount_percentage_per_input_key_type,
count(*) / sum(count(*)) over (partition by input_key_type) as event_amount_percentage_per_input_key_type
from (
select
* except(conciliation_id, conciliation_metadata, input_id, effect_date),
effect_date[0] as first_effect_date,
regexp_extract(input_key, '^[^.]+', 0) as input_key_type
from acquirer_conciliation.final_edge
where input_date >= :p_input_date.min and input_date <= :p_input_date.max
)
group by conciliation_status, input_date, first_effect_date, input_key_type, input_key, acquirer
order by all
My problem lies in my dashboard needs to filter data using some columns such as `acquirer` and `input_key_type`. But, when i use these columns as field filters, they will not recalculate the aggregation, only filtering the already calculated table, and obviously having a total of `input_amount_percentage_per_input_key_type` which is less than 100%.
Hence, it is my current understanding that I must use a filter on `acquirer` (in the subquery or the overall one), but then the problem arises. I could not, for the life of me, make a parameter that has as default values all distinct possible `acquirer` values (such as the result of `select distinct acquirer from acquirer_conciliation.final_edge`). The only thing i was able to do is to add this as a static list, which does not solve my problem.
However, the documentation here here seems to imply that should be able to do this. So I need some clarification on what this doc snippet actually means, and if it is in fact possible to add the possible values of `acquirer` dynamically.
I tried everything from changing the calculation places (on the query and on the dashboard) to using Custom Calculations with no luck at all.