Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hello, I'm trying to do something very similar to this situation: https://community.dataiku.com/t5/Using-Dataiku/Returning-the-Metric-Record-Count-in-a-Slack-message/... but in an email message and I cannot get it to work. I have a dataset called "RECORDS" and in the scenario, I am first running the metrics, then in a step after sending an email, trying to call the record count. Within my dataset RECORDS, I believe I have the record count metric turned on but when I try to call it in my email step using this:
${filter(parseJson(stepOutput_the_metrics)[‘PROJECT_NAME.RECORDS’].computed, x, x.metricId == ‘records:COUNT_RECORDS’)[0].value}
When I run the step, I always get the error ' freemarker.core.ParseException
Syntax error in template "tmpl0" in line 8, column 40: Lexical error: encountered "\u2018" (8216), after "".'
Any suggestions? I'm very confused about how to get the output itself from the metrics computation (${stepOutput_the_metrics}) as nothing returns when I call that. Please advise.
Operating system used: Windows
Hi,
I am unsure if it's an issue with the syntax with the exprenssion or an issue with freemarker.
You can instead just set variable step before, set a scenario variable with the metric and then only include the scenario name in your email template e.g ${variable_name}
toNumber(filter(parseJson(stepOutput_the_metrics)['DKU_TUTORIAL_TIME_SERIES_PREPARATION.orders_by_date_by_order_date_NP']['computed'], x, x["metricId"]=="records:COUNT_RECORDS")[0].value)
The DKU_TUTORIAL_TIME_SERIES_PREPARATION -> Project ID
orders_by_date_by_order_date is the dataset name it's not a partitioned dataset needs to add _NP at the end.
In my test I am just sending a webhook and I can confirm the variable is being passed:
Hi, I think Alex has now covered all the problems your expression had. I checked with mine as well and it's the same:
toNumber(filter(parseJson(stepOutput_Compute_Metrics)['PROJECT_ID.DATASET_ID_NP']['computed'], x, x["metricId"]=="records:COUNT_RECORDS")[0].value)
A few other things to highlight:
I also wrote a more extended post showing in more detail how to build these expressions step by step. Have a look at this post and scroll down for more details: