Guys, good afternoon!
I am doing this query to generate a dashboard, where I want to inform 2 (optional) parameters, but as you can see, it is not bringing any results. And when I only inform the customer, it is excluded from the result. How to solve this? Can you help me? Look at the attachment.
Hi @Lourival
When using Field Filters, you should not include the column.
Field Filter:
WHERE 1=1
[[AND {{filter}}]]
Other filters:
WHERE 1=1
[[AND column={{filter}}]]
Hi @flamber,
I did it here and it worked, but the documentation suggests informing the column, see: Redirecting…
My query looks like this:
SELECT UPPER(tb_cliente.nome_orgao),
tb_cliente.tipoAssinaturaPermitida,
EXTRACT(YEAR FROM tb_registrar_assinatura_cliente.ts_movimentacao) AS ANO,
EXTRACT(MONTH FROM tb_registrar_assinatura_cliente.ts_movimentacao) AS MES, COUNT(*) AS TOTAL
FROM tb_registrar_assinatura_cliente
INNER JOIN tb_cliente ON tb_cliente.id = tb_registrar_assinatura_cliente.id_cliente
WHERE true
[[AND {{CLIENTE}}]]
[[AND {{ANO}}]]
GROUP BY tb_cliente.nome_orgao, tb_cliente.tipoassinaturapermitida, EXTRACT(YEAR FROM tb_registrar_assinatura_cliente.ts_movimentacao), EXTRACT(MONTH FROM tb_registrar_assinatura_cliente.ts_movimentacao)
@Lourival
No, the documentation gives an example of simple filter with column. And then it gives a Field Filter example without column:
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html#the-field-filter-variable-type
I understand ... but it is in this part of the document that I have based myself.
I see in the attachment
@Lourival
But that section of the documentation is specifically for Optional Clauses [[ ... ]]
You can put any type of filter into optional clauses, but you still need to follow the guide for each filter type.
I understand, in any case I have managed to resolve here and I have acquired a knowledge for the next consultations. Thanks for your attention.