2 Replies Latest reply on Oct 2, 2016 9:19 AM by William Strouse

# How do I compare Current Sales Trends to Similar Time Segments from the Previous 2 Days?

Hello Vizzers,

My name is Will and I investigate fraud.

My current task to to build a viz with viz alerts triggered on suspect sales volume for high risk classes.

The volume of data is so large, and I am automating the script through Alteryx every 30 minutes, which means the max time period I have in the data at any one time is 3 days. I am tempted to put the calc in Alteryx to help the dashboard performance, but that is another issue.

Also, our sales have a normal trend throughout the day (low late at night and peaking around 4-5pm). The trick is to compare the wee hours of the night to themselves, and not peak sales time, as the late hours in when we experience the most attacks.

I am trying to compare the current sales volume/\$ to the average performance plus and minus 30 minutes for the previous 2 days.

Let Z= current average performance

X= yesterday’s time segment (24 hrs +/- 30 minutes)

Y=2days ago (48 hrs +/- 30 minutes)

The viz alert would trigger on sdv +/- 3 of Z compared to a moving avg(X,Y)

Where :

curdate-1410 minutes > x < curdate – 1470 minutes

curdate – 2830 minutes > y < curdate – 2910 minutes

I have it figured out mathematically, but having a lot of trouble with the date functions.

• ###### 1. Re: How do I compare Current Sales Trends to Similar Time Segments from the Previous 2 Days?

Hello William

There are a number of example date functions and workbooks that are found here:  Calculation Reference Library

Let us know if one of these gets you going and if you get stuck, let us know where to help provide a bit more insight.

Patrick

• ###### 2. Re: How do I compare Current Sales Trends to Similar Time Segments from the Previous 2 Days?

Thanks Patrick:

I decided that given the size of the data I was working with and the accuracy needed on the means I would be calculating against, the best way was to create a separate data source that I summarized from a 90+ day time sample.

This Viz relies on speed and performance for the end users, so no time to waste computing nested calcs like that.

So with some guidance I created a table grouped on each class and an hour segment of the day, then published that sum table in the same workflow currently automated.

The CORRECT ANSWER FOR THE ISSUE: was to create a table calculation finding the means by class and by hour which I did, what I DID NOT DO was remember to alter the date and time filters used for each page, as the mean-tables were being applied on each page of the workbook.

If the user moved the date range to a day, or the last 2 hours, the mean tables were moving to that same time.

DUH...An obvious error but a good reminder to pay close attention to the filer details when building these kinds of dashboards.