Skip to main content
Oct 14, 2022 8:23 AM UTC
Question

Can I create a "dynamic" load script?I'm trying to create a filter for a component which changes depending on the input of the user.

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?

2 replies

Oct 17, 2022 6:28 AM UTC

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

Level 0
Oct 18, 2022 10:10 PM UTC

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.