NULL as a variable?

Hey, I want to have a conditional where clause to filter out only values that are null if I would type a ‘null’ into a text box but the text variable doesnt seem to work in this situation. Is there any other way to make something like this doable:

[[WHERE amount is {{null_variable}}]]

Edit: I found a quick workaround which looks like this:

[[WHERE amount is null AND 1 = {{one}}]]

But still maybe someone knows if there is a chance to connect variable itself to a null without introducing a random ‘1’ which users who didnt code it wouldnt understand why they have to enter 1 if they want rows with null?

Hi @tautvydas.valatka
I haven’t tried it, but I would do something like this (simple Text filter):

[[WHERE CASE WHEN {{null_variable}}='null' THEN amount is null ELSE amount = {{null_variable}} END]]

Yeah that does the trick. Would still like to have a feature where the inserted value would act as more than just a text to be able to group, order and do some other stuff without workarounds with data. But thanks a lot though, for now this is the best solution for what I was looking for,

I would have security concerns with something, where columns/tables/schema/etc could be switchable to an arbitrary value.
There’s a PR open for support of something like that. I’m not sure if it will ever make it into Metabase or what the security implications would be: