Skip to main content

I'd like to change the query of an analysis and upload the analysis. The documentation notebooks show how to extract the queries but not how to change them or upload them.

 

Is there a way to change the analysis object directly or do you use the backup_content method for this.

 

I find the working with the extracted json files a hassle since they are very nested and use the same keys. I've tried finding the components and their "path" recursively but that didn't work as desired. I haven't tried importing it with pandas. Any tips here are appreciated.

 

 

For manipulating the analysis directly, I imagined something like this:

analysis.draft.componentse"component_name"].queries = myquery

 

But that didn't work.

 

Also I found some references to older notebooks "https://python.celonis.cloud/docs/pycelonis/en/latest/notebooks/99_Use_Case_Copy_Analysis.html 50"

 

(https://community.celonis.com/t/pycelonis-script-merge-analysis-sheet-from-two-different-analyses/2736/2)

 

Are those still around?

 

All the best,

Saša

Hi @sasa.redze12 ,

 

Although not a direct answer to your question, I have 2 ideas that might help:

 

  1. Isn't there a replace function available? You could use this to replace the old query with the new one (assuming you want to replace all occurrences).
  2. Another option, if you plan to do this regularly, is to use a variable which contains the query that should be executed. If I recall correctly you can set variables in pycelonis, allowing you to easily change the query used. I often use this trick to allow a user to set certain logical elements (e.g. notion of an event or abstraction) through drop-downs.

 

Hope this helps!


Hi Joos,

 

thank you for taking the time to answer.

 

Could you elaborate on your first answer? I haven't found a replace function. Maybe someone else knows more?

 

Your second suggestion is quite informative but probably not applicable to my use case.

 

I created a copy of a workspace and used the new notebook to generate a list of potential cases where the CASE WHEN statement needs to be adjusted. I then added a new column where I changed the pql statement. now I would like to loop over that list in pycelonis and replace the old pql statement with the new pql statement..

 

I got everything running except the part where I can change the pql statement within pycelonis and reupload the analysis.


Hi Joos,

 

thank you for taking the time to answer.

 

Could you elaborate on your first answer? I haven't found a replace function. Maybe someone else knows more?

 

Your second suggestion is quite informative but probably not applicable to my use case.

 

I created a copy of a workspace and used the new notebook to generate a list of potential cases where the CASE WHEN statement needs to be adjusted. I then added a new column where I changed the pql statement. now I would like to loop over that list in pycelonis and replace the old pql statement with the new pql statement..

 

I got everything running except the part where I can change the pql statement within pycelonis and reupload the analysis.

Hi @sasa.redze12 ,

 

I guess this function should do the trick:

pycelonis.celonis_api.process_analytics.analysis — pycelonis 1.5.14 documentation

 

Let me know if this helps!


Reply