Skip to main content
Solved

i want to use conditional filter in "load script" section by "Case When "

  • July 8, 2022
  • 6 replies
  • 18 views

Forum|alt.badge.img+12

How can I set conditional filter in load script page? I have tried Case When, but it gives me error. Is there anyone who has suggestions?

Filter "xx"."yy" = <%= option1%> (it works)

 

 

i want to do multiple conditions like that in component filter

case when <%=option1> = 'a' than Filter "xx"."yy" = 'value' ;

case when <%=option1> = 'b' 'than Filter "xx"."yy" = 'value2' end

 

Is there any way to add conditional filter in the component filter section?

 

 

Best answer by tony.hoang11

Can you try reordering it to something like this? FILTER "xx"."yy" = CASE WHEN <%=option1%> = 'a' THEN 'value' WHEN <%=option1%> = 'b' THEN 'value2' END ;

6 replies

I made some test, but I couldn't get the results.

 

Nevertheless here my filter. Maybe it will give you some ideas

 

FILTER

CASE WHEN "CV_POLIZA"."COD_RAMO" = 111

THEN

CASE WHEN PU_COUNT(CONSTANT(),"CV_POLIZA"."NUM_POLIZA") > 1 THEN 1

ELSE 0

END

ELSE 0

END

>= 1

OR

CASE WHEN "CV_POLIZA"."COD_RAMO" = 110

THEN

CASE WHEN "CV_POLIZA"."NUM_POLIZA"= 'POL-04' THEN 1

ELSE 0

END

ELSE 0

END

>= 1

 


erik.zwick12
Celonaut
Maybe instead of using a component filter this could be achieved in the component itself using nested case when statements. Has that been tried yet?

Forum|alt.badge.img+12
  • Author
  • Level 2
  • July 14, 2022

yes , i have tried, but the problem is i am using dynamic filter, and it doesn't return the exact keyword in the table.


Forum|alt.badge.img+2
  • Level 0
  • Answer
  • July 15, 2022
Can you try reordering it to something like this? FILTER "xx"."yy" = CASE WHEN <%=option1%> = 'a' THEN 'value' WHEN <%=option1%> = 'b' THEN 'value2' END ;

Forum|alt.badge.img+12
  • Author
  • Level 2
  • July 21, 2022
Can you try reordering it to something like this? FILTER "xx"."yy" = CASE WHEN <%=option1%> = 'a' THEN 'value' WHEN <%=option1%> = 'b' THEN 'value2' END ;

yes, it works properly. thank you


Forum|alt.badge.img+12
  • Author
  • Level 2
  • July 23, 2022
Can you try reordering it to something like this? FILTER "xx"."yy" = CASE WHEN <%=option1%> = 'a' THEN 'value' WHEN <%=option1%> = 'b' THEN 'value2' END ;

Hi @ALL

 

let me update my question.

one the dynamic filter should execute the null values in the table.

 

FILTER "table". "column" = CASE WHEN <%=option1%> = 'abc' THEN NULL END;

 

all other filters work but i cannot return null values from same table. I have have tried this formula 

FILTER "table". "column" = CASE WHEN <%=option1%> = 'abc' THEN Filter_TO_NULL("table". "column") END;

 

but when i have tested, i saw that i didn't bring up all null values from table. Does anyone have an idea?