Create a dashboard with a formula in Analytic

Create a dashboard with a formula in Analytic

Hi everyone,

I need to know the average date of purchase per a product per a customer.

Here is how I count it.

For example:

Customer A bought product B in Jan. I count it "1"
Customer A bought product B in Feb. I count it "1"
Customer A bought "0" in Mar. I count it "0"
Customer A bought product B in Apr. I count it "1"
Customer A bought product B in May. I count it "1"
Customer A bought "0" in Jun. I count it "0"
Customer A bought product B in July. I count it "1"
Customer A bought product B in Oct. I count it "1"
Customer A bought product B in Nov. I count it "1"
Customer A bought "0" in Dec. I count it "0"

Add all the number "1" and "0" I have "7" , then I divide with "12" (month)  7/12 = 0.58333333333
then I multiply it by 30 (days) 0.58333*30 = 17.5 (days) as an average date of purchase per a product per a customer

How can I add this formula in to Analytic as a Dashboard?
In this Dashboard, I just select customer, date of time and product, and it will show me the number, just like the attached image.

Thank you so much for reading.