Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld Online 2021, May 10-12: Our Free, Virtual, Global Event REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
MEBG93
Creator
Creator

Always show last 30 dates in chart (bar or pivot table)

Hello experts,

I've been trying several ways to deal with this but haven't hit spot. I want to show in a bar chart the last 30 dates for sales, no the last 30 days; and if I select a random date, it should show the last 30 dates from there.

So I've tried COUNT({< DATE={">=$(=max(DATE, 30))<=$(=max(DATE))"}>}salesID). It works without any selections, but when a date is selected it shows only the selection. I want the last 30 dates available from that selection.

 

Thanks and Happy Holidays!

4 Replies
Vegar
Partner
Partner

 

By using  max(DATE, 30) you get the 30th largest DATE value. It is not 30 days from Max(Date). Consider using max(DATE)-30. 

 

Regarding you trouble when selecting.

Consider this data model.

image.png

If you use SET analysis on DATE, but make selections on Date, Day, Year or Month you wlll only get the part of the SET that also is included in your selections. To avoid this you should try to cancel these selections in you set.

COUNT({< DATE={">=$(=max(DATE)-30)<=$(=max(DATE))"}, Year, Month, Date, Day>}salesID)

 

I hope these two tips will help you to solve your problem.

 

Happy holidays!
Vegar

 

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
danilostochi
Creator II
Creator II

hi, 

try this,

count({<date={">=$(=Date(AddMonths(max(date),-1)))<=$(=Date(max(date)))"}>}sales) //period 30 days

+55(44) 9 9993-3605, WhatsApp
E-Mail or Skype - danilo16stochi@hotmail.com
MEBG93
Creator
Creator
Author

Hello Vegar,

Thanks for your response, but it didn't work out. If I insert the other calendar dimensions it doesn't help when selecting a date. For example, if I select 2019-12-10, I want to show that selection and the previous 30 dates, but it only shows the sole selection. 

I've also tried limiting the dimension to the top 30 results, but it shows the 30 largest SalesID count, which is wrong. You know if there's a way to change that criteria to show the top 30 dates instead of the top 30 salesID count?

Cheers!

Vegar
Partner
Partner

Its hard to help without having a common data sample to talk about. Please inspect, commant and maybe adjust my sample datamodel to fit your scenario. 

If you do we might be able to help you.

 

BR
Vegar

Plees ekskuse my Swenglish and or Norweglish spelling misstakes