How it works...

Since our data is at the line level, we start by using GROUPBY to summarize our data by Order and storing this table within the __Table variable. Within our GROUPBY function, we calculate the minimum value of the ReceiveDate column per Order. Next, we calculate the maximum and minimum ReceiveDate within __Table by using MAXX and MINX, respectively. The maximum ReceiveDate is stored in the __Max variable, while the minimum ReceiveDate is stored in the __Min variable. We also calculate the number of rows within __Table using COUNTROWS and store this number in the __Count variable.

Now, we can calculate the frequency of orders by using DATEDIFF to find the difference between __Min and __Max in hours (HOUR) and then dividing by the number of orders with __Count. We store this value in the __OCT variable and simply return the value of __OCT as the value of the OCT (Hours) measure.