Load Script - with Variable

Hi All

I would like to limit the scope of an anylsis by filtering some company codes in a load script.
I have create a variable as text replacement in which I have put the list of company code:

Variable Name= ShopCC
TexT/Replacement= ‘CH01’,‘IT13’,‘FR02’,‘FR08’

the load script is

FILTER “EKPO”.“BUKRS” IN (<%=ShopCCode%>);

Unfortunaltly I get an error saying that there iwas a syntax error in the load script.

Any Idea please ?

thank you

Hi MehdiBoug,

Welcome to celonis community :slight_smile:

I found a contradiction in your code: you wrote that your variable is called ‘ShopCC’ but in the code you use the variable name ‘ShopCCode’. Once you’ve sorted that out it ought to work fine since the syntax is correct.

If you have more questions, feel free to make more forum posts and we’ll be happy to help.

Best wishes,
Calandra

Hi MehdiBoug,

you haven’t mentioned whether the problem has been solved but in case your still having issues its worth knowing that variables can’t be when in loading scripts so you may well be better off adding sheet filters to every page if you need dynamic filtering.

Best Wishes,
Calandra

Hey @c.eckert ,

I have a similar questions and wondered if you can answer it here.
We want to filter the whole Cycle Times Analysis to cases that flow through the activity selected as a subprocess (variables “from” and “to”).

However when I enter the filter as “load script” of the whole analysis
Celonis1

I get
Celonis2

The filter works if I apply it as Sheet-filter. But we rather want to have it as Analysis filter, not set on every sheet. Is this possible?

Thank you for your help.

BR,
Marcel

Hi Marcel,

I’m afraid it’s not possible to use variables in an analysis filter.

This is because the Analysis filter effects the data available to be displayed in the analysis. If you were to change the subprocess defined by ‘to’ and ‘from’ to a more common one, those extra cases couldn’t just be included (like they are with sheet filters) because the cases aren’t available to the analysis, as they haven’t been loaded. The whole analysis needs to be reloaded, to include more cases. To avoid these problems the analysis throws up an error. I presume ‘to’ and ‘from’ can be set by viewers using a button. In such cases it’s better to use sheet filters anyway so the viewers can easily how many cases they are excluding. If you don’t want viewers to adjust the filter, I’d just hard code the filter by just writing the activity names as text into the filter.

If you use an analysis filter, or the same sheet filters on all sheets, its generally a good idea to add a text component explaining which filter is active to prevent confusion.

Also as an alternative to Process Equals, you could use MATCH_PROCESS_REGEX() if you wanted as it is more flexible.

The sheet filters would then be:

FILTER MATCH_PROCESS_REGEX(<%= from %> >> (ANY)* >> <%= to %>) = 1;

‘>>’ means directly followed by

‘(ANY)*’ means any number of activities (including 0) can come between ‘from’ and ‘to’.

MATCH_PROCESS_REGEX() returns a 1 for cases with the specified process path, so together with ‘= 1’ it builds a logical condition for use in the filter.

In case you want to enable more flexible settings such as multiple possible ‘from’ activities, this can also be achieved with this function so its worth reading up the help pages.

Does this answer your question.

Best wishes,

Calandra

Hey Calandra,

thanks a lot for your prompt response. I understand the circumstance now, that variables cannot be used in load script of the analysis - and yes, the variables can be set by the viewer via a dropdown.

I tried, but got the following (not really valuable) error:
Celonis3

Did the filter work for you?

BR

Hi Marcel,

Oh, you’re right. I’m so sorry. When I wrote down the syntax, I forgot to specify you need to add the activity table. the syntax is actually

MATCH_PROCESS_REGEX(“activity table”.“activity names in English”, <%= from %> >> (ANY)* >> <%= to %>)

Also from your error message its looks like a there might be a single comma is missing in front of “Approve Credit Check”.

I’m sorry about that.

Best wishes,

Calandra