Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
razvan_brais
Creator III
Creator III

Last 7 days average barchart

I`m trying to calculate last 7 days average of sales and put it in a bar chart , but when I add the expression it shows values for every day. I want to show just one bar for the average.

This is the expression:

sum({<DATE = {">=$(=Date(GetFieldSelections(DATE)-7))<=$(=Date(GetFieldSelections(DATE)))"}>} Sales) / 8

What is wrong , or what am I doning wrong?

Thank you

1 Solution

Accepted Solutions
sunny_talwar

Apologize, I should have pointed that out. Select 'Show Total' on the dimension limits tab

Capture.PNG

View solution in original post

14 Replies
mohammadkhatimi
Partner - Specialist
Partner - Specialist

What u r adding in dimension tab DATE or Month???

razvan_brais
Creator III
Creator III
Author

Date

mohammadkhatimi
Partner - Specialist
Partner - Specialist

Use Month..

Anonymous
Not applicable

Try this:

sum({<DATE = {'>=$(=Max(DATE)-7)<=$(=Date(Max(DATE))'}>} Sales) / 8

Regards!!

razvan_brais
Creator III
Creator III
Author

Well I kinda need the Date dimension , because in the same bar chart I will have total sale for today , total sales for a week ago and the average for last 7 days

Not applicable

sum({$<DATE = {">=$(=Date(max(DATE)-7))"}>} Sales) / 7

try this please

razvan_brais
Creator III
Creator III
Author

I wrote this expresion , but the result is not shown on my chart

Anonymous
Not applicable

Hi,

Create two vars:

vMaxDate = '=Date(Max(Date))' (without quotes)

vMaxDatePrev = '=Date(Max(Date)-7)' (without quotes)

sum({<DATE = {'>=$(vMaxDatePrev)<=$(vMaxDate)'}>} Sales) / 8

Regards!

razvan_brais
Creator III
Creator III
Author

It still shows me bars for each day. I would like to make only one bar that shows the total sum for a week