This table aims to calculate the standard deviation of the number of sold dishes on the same weekday and hour across a selected date range.
The filters applied to the table above are:
- Branch
- Weekday
- order hour
- order_date
I wrote two expressions to calculate the STDv, the one in Red is wrong and the one in Green is the correct value.
I created the table above to debug both expressions. The end goal is to have a table like this:
Because this table does not have the order_date dimension/group by in the well, the std expression is now all 0’s while the Std Deviation has values despite being the wrong one. This table is supposed to show the standard deviation of every hour of every weekday.
Here are the expressions:
Number of Dishes
sum({total_item_quantity})
Std Deviation
stdevpOver(sumOver({total_item_quantity},[ {dummy branch name},{order_date},{order_hour},{branch_id}],PRE_AGG),[{dummy branch name},{weekday_full},{order_hour}],PRE_AGG)
std
stdevpOver(sum({total_item_quantity}),[{dummy branch name},{weekday_full},{order_hour}])
It is worth mentioning that there are multiple Items sold in any hour (there are other item dimensions that are not part of this table). So, taking the sum(total_item_quantity) is a must to get the total number of items sold in any hour.
How can I get the correct std to show up in the second table?