Skip to main content

So, I'm trying to implement a filter that changes depending on the input of the user. A button dropdown was included to collect the input of the user, said button contains three options which change the value of a dynamic variable, the possible values for this variable are 0, 1 and 2.

 

Lastly, I wish to filter a component depending on the value of said variable. I tried implementing a load script as follows:

 

FILTER DATEDIFF(mm, VBAK.ERDAT, VBAK.MBDAT) CASE WHEN <%=variable%> = 1 THEN >60

WHEN <%=variable%> = 2 THEN <=60

ELSE END

This solution does not work. Any help?

Hmmm.... maybe I am not getting it, but it seems the syntaxis is wrong, and the logic.

 

I think it should be:

FILTER ( DATEDIFF(mm, VBAK.ERDAT, VBAK.MBDAT) > 60 AND <%=variable%> = 1 ) OR ( DATEDIFF(mm, VBAK.ERDAT, VBAK.MBDAT) <= 60 AND <%=variable%> = 2)

 

 

BTW that's a component filter

 

HTH


Hello Martin,

 

Guillermo's suggestion should work for your needs. To explain more in depth:

CASE WHEN can not be used to designate a comparator.

<%=variable%> = 1 THEN >60 is invalid syntax, but <%=variable%> = 1 THEN 60 is valid syntax. This would have required you to place > before the CASE statement, which would not have worked for your needs.

 

Additionally, variables are not supported in Analysis level load scripts due to the way Celonis processes analysis level load scripts. They can still be used in sheet level and component level load scripts. If you need this to affect a whole analysis, you can add this load script to every single sheet in the analysis.


Reply