Skip to main content

Hi all,

 

my Question is: is it possible to use a CASE WHEN Statement where the condition is a comparison between a variable and a string?

Like:

CASE WHEN <%=variable%> = 'value' THEN ...

 

I work in Celonis Studio with PQL and created a variable in the Variables Section. What I want to do is filter a chart component depending on what timespan (hour, day...) I selected in a button drop down. Here is a code snippet:

CASE WHEN <%=timespan_picker%> = 'HOUR' THEN

ROUND_<%=timespan_picker%>(PU_FIRST (DOMAIN_TABLE...

 

When I try it like this I get an Error which says: Table not found

 

Thanks for your help

N.

Hi Siegmund,

 

You can use ROUND_<%=timespan_picker%>(PU_FIRST(...)) in your formula without the case when if your variable has YEAR, MONTH or DAY.


Hi Cátia,

thanks for your answer.

That is already working but i have a chart where the user can pick between different timespans (HOUR, DAY, MONTH) and depending on what he picked the chart shows the number of cases which are moving go a certain area(for each hour or each day...)

 

So I need to assign different Formats to the Formula output. When the user picks DAY or MONTH the chart works but when he picks HOUR the format is still '%Y-%m-%d'.

 

So when the variable value is 'HOUR' I would like to format the output to FORMAT('%H:%M') and then the chart is on a hourly basis and when the variable value is != 'HOUR' I would like to format the output to FORMAT('%Y-%m-%d') and see days or months.

 

I mean something like this:

 

CASE WHEN <%=timespan_picker%> = 'HOUR' THEN

ROUND_HOUR(PU_FIRST (DOMAIN_TABLE("_CEL_OUTBOUND_ACTIVITIES"."_CASE_KEY"), "_CEL_OUTBOUND_ACTIVITIES"."_EVENTTIME", "_CEL_OUTBOUND_ACTIVITIES"."_ACTIVITY_EN"='Move to Sorter Split Area' )) ( and then FORMAT('%H:%M'))

 

ELSE

 

ROUND_<%=timespan_picker%>(PU_FIRST (DOMAIN_TABLE("_CEL_OUTBOUND_ACTIVITIES"."_CASE_KEY"), "_CEL_OUTBOUND_ACTIVITIES"."_EVENTTIME", "_CEL_OUTBOUND_ACTIVITIES"."_ACTIVITY_EN"='Move to Sorter Split Area' )) (and then FORMAT('%Y-%m-%d'))

 

END

 

Best

Niklas


You can try something like this

 

TO_STRING(ROUND_<%= timespan_picker %>("TABLE"."COLUMN"),  FORMAT(<%= format %>))

 

You need to add a variable for the format.


It worked, thanks a lot. 🙌


Reply