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

Hi Calandra,

thank you for your help. Unfortunately the Code provided does not work either.
Is there anything bad about using the code below, as it also works?:

FILTER PROCESS EQUALS ANY to <%= from %> to ANY to <%= to %> to ANY;

Thank you for an answer.

BR,
Marcel

Hi Mankem,

If you only want to use simple subprocess Process equals is fine. The code you posted is also fine (as long as a solution works that’s the most important thing :wink: ) but for the record this simpler Filter does the exact same thing same thing.

PROCESS EQUALS <%= from %> TO ANY TO <%= to %>;

So long as you don’t explicitly write “START” in front of the first activity and “END” after the last activity, the “ANY to” and the “to ANY” are implicitly assumed by the implementation.

Just in case anyone with a similar problem reads this and it doesn’t work for them: if, in the button drop down components where ‘from’ and ‘to’ selected, the wrapping characters aren’t set to single commas it is necessary to write single commas around the variable names in the filter.

Best wishes,

Calandra

1 Like

Hi Marcel,

I think the reason why the formula that Calandra provided doesnt work is that it looks like from your screenshot that you have a CPM4.3 or 4.4, where MATCH_PROCESS_REGEX is not included yet.

Cheers
David

Hi David,

we are using CPM 4.5 on-premise :slight_smile:

Cheers,
Marcel

Great information, thank you!! :slight_smile:
I just tried your without the ANY TO and TO ANY in the beginning/end and the result is the same.

Hi Marcel,

Ah okay. Then it should work. Did you write =1; at the end?
But if it now works with PROCESS EQUALS then it’s fine :slight_smile:

Cheers
David