cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MakeTimeseries with CountDistinct

wellpplava
Contributor

Hello, everyone!

I have a metric that stores each new purchase of a customer. The problem is that, if the customer buys 3 items, I have 3 values ​​in my metric.

So I stored the orderid as dimension.

With a single value I got:
timeseries `beta-orders` = sum(`log.beta-orders`), by: {step, orderid}
| filter step == "Booking"
| summarize count = countDistinct(orderid), by: {step}

but now I need a graphical view, counting how many unique orderids were generated
Is it possible to use MakeTimeseries with CountDistinct?

4 REPLIES 4

StrangerThing
Organizer

You may be able to use the "dedup" command instead of summarizing, which would leave your data in a timeseries for charting.

timeseries `beta-orders` = sum(`log.beta-orders`), by: {step, orderid}
| filter step == "Booking"
| dedup orderid

unfortunately it didn't work. From what I saw, the orderid column, the values ​​are not repeated, the problem is in the array that quantifies the values

wellpplava_0-1728582251531.png

 

The only way I can see to do it is to just append the same timeseries with the summarize so you'll end up with one value for the distinct count but also have the timeseries data. This doesn't make the data suitable for a chart, however. 

If you're trying to display this on a dashboard you may consider a single value tile that contains the summarize command with the number of orderids beside a chart of the timeseries data.

krzysztof_hoja
Dynatrace Champion
Dynatrace Champion

If you say: "The problem is that, if the customer buys 3 items, I have 3 values ​​in my metric", does it mean that you have also something like "itemId" as dimension of this metric?

I see that this metric is defined as a metric from log. Can you share your metric definition?

Featured Posts