Solved

METRICS MAQL - AVERAGE SALES OF THE LAST 10 DAYS


Good Morning!I need help to make a metic where I need to display the average sales for the last 10 days

 

I tried to do it this way and I was not successful

 

SELECT AVG(Sales WHERE (Date “in this case the day”) BETWEEN THIS - 10 AND THIS)

In short, I need to return the average sales volume of the last 10 days.
Thank you very much in advance!
icon

Best answer by Iva Gasparekova 1 June 2021, 16:27

Thank you for the screenshot, appreciated!
Please check my example below:
 

SELECT AVG(VLR_VENDAS_BASE_SEM_DEVOL_SEM_FRETE) WHERE (Date (Data) BETWEEN THIS - 9 AND THIS)


I would substitute the "Day of Year (Data)" with simple "Date (Data)" attribute if possible.

View original

5 replies

Userlevel 2

Thank you for the screenshot, appreciated!
Please check my example below:
 

SELECT AVG(VLR_VENDAS_BASE_SEM_DEVOL_SEM_FRETE) WHERE (Date (Data) BETWEEN THIS - 9 AND THIS)


I would substitute the "Day of Year (Data)" with simple "Date (Data)" attribute if possible.

Thank you for the screenshot, appreciated!
Please check my example below:
 

SELECT AVG(VLR_VENDAS_BASE_SEM_DEVOL_SEM_FRETE) WHERE (Date (Data) BETWEEN THIS - 9 AND THIS)


I would substitute the "Day of Year (Data)" with simple "Date (Data)" attribute if possible.

@Iva Gasparekova 
It worked out!!I'm grateful for the help!!Thanks
Userlevel 2

Good Morning!

I would probably adjust your metric just a bit:
 

SELECT AVG(Sales) WHERE ("DATE_Attribute" BETWEEN THIS - 9 AND THIS)



Could you confirm that "Sales" stands for a Fact or a Metric, which uses Fact, please?

Good Morning!

I would probably adjust your metric just a bit:

SELECT AVG(Sales) WHERE ("DATE_Attribiute" BETWEEN THIS - 9 AND THIS)

Could you confirm that "Sales" stands for a Fact or a Metric, which uses Fact, please?

I'm wearing a FATO

 

Userlevel 2

Awesome, happy to help  anytime!

Reply