how would I return the difference (in days) betwee...
# gd-beginners
h
how would I return the difference (in days) between two dates using MAQL? This help question points to a Date Arithmetic page that no longer seems to exist. I would like to do something like:
Copy code
(last_updated_date - created_date, days)
Note that both
last_updated_date
and
created_date
would be database date fields. I am not trying to compare to today's date.
i
Hi! Sorry for the dead link, I will update it in a community post as well. This article was moved to the Classic Documentation: https://help.gooddata.com/classic/en You can still find it here: Date Attribute Arithmetic
Community post updated. Please be so kind and check the article - I’d be happy to assist you further, if there’s anything unclear.
h
To specify that the metric should be aggregated at the event level, add the event attribute to the report from the How pane.
I am not sure what the document means by the How pane in this context? I don't see it in the picture of the LDM
here is the query:
here is the analysis interface (it doesn't appear to be working at the moment)
here's the data model:
@Ivana Gasparekova would you know what I am doing wrong?
j
Hi @Hesseltje van Goor, MAQL in your query calculates the date difference for each record of CRM Deal dataset. I think you miss instruction for the query engine how to reduce it from cardinality of the CRM Deals dataset to just one number or different number of results depending on how you break down the metric in your insight using attributes in buckets like Rows, Columns, View By etc.. If you want to display for example average the metric should look like:
Copy code
select AVG(select Date (Updated at) - Date (Created at) by Id (CRM Deals) )
you can use other aggregation function such as SUM/MIN/MAX instead of AVG depending on what you actually want to see in the result
The metric you have created will display probably if you add Id (CRM Deals) into Rows
h
yes, I was hoping to have something per row, rather than aggregated
your suggestion worked, I am able to see the unique handling time per row
I'll have a go with the average, that sounds like it could be really useful too