I use multicolumn for ENUM type [‘pending’,‘partially_fulfilled’,‘fulfilled’,‘returned’,‘exchanged’] and query like this:
WHERE
(orders.status = ANY ({{ order_status_multi.value }}))
Now the problem is that the order.status column in DB table can contain also NULL values and this causes that when I do not select any of the values [‘pending’,‘partially_fulfilled’,‘fulfilled’,‘returned’,‘exchanged’] in the multi-select box the query returns no rows.
I would probably do this with changing the values to
If null was an option in the array order_status_multi.value (multiselect component?), then choosing null/‘Undefined’ there would also return rows where order.status = null in addition to any of the selected options.
If you want to return rows where order.status = null if no values are selected in the multiselect, you could do something like this:
WHERE (orders.status = ANY ({{ order_status_multi.value.length == 0? [null] : orders_status_multi.value }}))
Does that help here? It might also be worth noting that multiselect1.value is an array of the selected values, and multiselect1.displayValue is an array of the selected display values
SELECT
Shop,
Month,
SUM(ProductA) as Units_ProductA,
FROM
{{ rawQuery.data }}
WHERE
1
AND Shop = CASE WHEN {{ shopFilter.value }} <> '_default_' THEN {{ shopFilter.value }} ELSE Shop END
GROUP BY
Shop,
Month
Then on my “shopFilter” I setup the initial value as _default_. So if the user doesn’t select the shop the query would be:
SELECT
Shop,
Month,
SUM(ProductA) as Units_ProductA,
FROM
{{ rawQuery.data }}
WHERE
1
AND Shop = Shop
GROUP BY
Shop,
Month
If the user selected a shop then the query would be like:
SELECT
Shop,
Month,
SUM(ProductA) as Units_ProductA,
FROM
{{ rawQuery.data }}
WHERE
1
AND Shop = {{ shopFilter.value }}
GROUP BY
Shop,
Month
Is the null value in your multiselect null or 'null'? If it is the value is null and orders.status = null, then orders.status = ANY ( {{ [null] }} ) should work. That is for postgres at least, an array inside of ANY ( )
Hi everyone,
I checked all the documentation on this but I have the exact same problem and wanted to check if there was any solution in the meantime.
My select field works with the following integration in my postresql code:
WHERE ({{! select1.value }} OR "Location"."internalName" = {{ select1.value }})
Somehow, a multiselect field, within the same query won´t work with the following code:
WHERE ({{! multiselect1.value }} OR "Location"."internalName" = ANY({{ multiselect1.value }})
I get that the multiselect1.value is an array other than the select1.value that is only one value. I think that is why the ! solution is not working with the multiselect1.value. I tried .length = 0 and other workarounds but none of them worked. Like ckissi I want to see all the data when multiselect1 is not used and filter for selected locations when it´s used...