Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
varmekontrol
Creator
Creator

Filter barchart depending on selection on date

Hi

Can anyone in here help me figure out how to make a bar chart show the last 24 hours, last week (and so on) depending on the date selected?

Right now I am just using 

if(created>=today()-1, values)   //For the last 24 hours
if(created>=today()-7, values) //AGGR daily sum of values

But this is only works for that specific date range. 
So if I am to view something that is not within the 24 hour and 7 day selection the bar chart is blank. 

What I need, is to write something that is dynamically and adapts to the selected date. 

If i choose 01-03-2019. I would like to show the 24 hours of that date in the barchart. 
If i choose 01-03-2019. I would like to show the week Monday-Sunday this date is a part of.. 

//something like

If created day 01-03-2019 is selected (show created>=today()-1)
if created day 01-03-2019 is selected (show Monday-Sunday of created>=today()-7)

Have no idea on how to incorporate my selection in the expression.. ??

 

 

 

Labels (3)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

/*sales of previous day*/
sum({<[created]={"$(=date(max([created]-1)))"}>} Amount)

/*sales of selected week*/
sum({<created={">=$(=WeekStart(max(created)))<$(=dayname(WeekEnd(max(created))))"}>} Amount

View solution in original post

2 Replies
Vegar
MVP
MVP

/*sales of previous day*/
sum({<[created]={"$(=date(max([created]-1)))"}>} Amount)

/*sales of selected week*/
sum({<created={">=$(=WeekStart(max(created)))<$(=dayname(WeekEnd(max(created))))"}>} Amount
Vegar
MVP
MVP

If you want to include the current date to previous date value in example above you can do this
sales of previous day and current day*/
=sum({<[created]={"$(=date(max([created]-1)))","$(=date(max([created])))"}>} Amount)