Skip to main content

Hello Community,

how can I check if a variable from the new views is NULL? My challenge is to not use an filter in a PU_FUNCTION when the variable is empty.

Variable: VAR_CONDITION_FILTER

Example Value with multiple selection: ‘Y001’, ‘Y020’, ‘Y300’

I want to use the variable in a PU_SUM Filter statement like in this way.

PU_SUM("VTTK", "FREIGHT"."FREIGHT_CONVERTED", CASE WHEN '${var_condition_filter}' IS NOT NULL THEN "FREIGHT"."CONDITION" IN (${var_condition_filter}) END )

But this don’t work. Error:

A PQL error is preventing this query from executing.

Syntax error near aIN] after reading aPU_SUM("VTTK", "FREIGHT"."FREIGHT_CONVERTED", CASE WHEN '${var_conditon_filter}' IS NOT NULL THEN "FREIGHT"."CONDITION" ] at line 9. Please refer to PQL documentation for available syntax.

 

This here works, but I need the check if the variable is empty to avoid errors and to avoid that users has to select all the possible values.

PU_SUM("VTTK", "FREIGHT"."FREIGHT_CONVERTED", "FREIGHT"."CONDITION" IN (${var_condition_filter}) )

 

I hope you understand my question? → If a Variable with multiple selection is empty then don’t filter in PU_SUM, if the variable has entries like (‘Y001’, ‘Y020’, ‘Y300’) then filter on field FREIGHT_CONDITION in PU_FILTER statement.

Thank you so much,

Thomas

 

 

Hey, I solved it with this workaround.

If you have a better idea, let's hear it 😉

 

CASE WHEN COALESCE(${var_condition_filter},'') != 'None' THEN 

PU_SUM("VTTK", "FREIGHT"."FREIGHT_CONVERTED", "FREIGHT"."CONDITION" NOT IN (${var_condition_filter}))

ELSE

PU_SUM("VTTK", "FREIGHT"."FREIGHT_CONVERTED")

END

 


Reply