Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Nive
Partner - Contributor III
Partner - Contributor III

Find Previous date range values from selected date range

Hello Guys,

I have a requirement where i need to calculate previous date range value from selected date range.

the number of days selected in the date range will be the count for previous date range sales to be calculated.

For eg: consider a table having sales data from 2018 till date.

if i select date range from 1/11/2019 to 1/15/2019 i wanted to show sales of previous date range before 1/11/2019. ie., data from 1/5/2019 to 1/10/2019 should be shown based on selected date count.

if i select the whole month(1/4/2019 to 30/4/2019), then (2/3/2019 to 31/3/2019) sales should be shown.

if 1/1/2019 to 1/25/2019 is selected then prev date values like (6/12/2018 to 31/12/2018) is shown

Thanks in Advance.

1 Solution

Accepted Solutions
Nive
Partner - Contributor III
Partner - Contributor III
Author

Thanks kashap.. 

I got my ans after several tries..

=Sum({<date={"<=date(max(date)-count(distinct date)) >=date(min(date)-count(distinct date))"}>}value)

View solution in original post

2 Replies
Kashyap_R
Partner - Specialist
Partner - Specialist

Hi

try this

Sum({<[Date] ={"<$(=Date(max([Date])-(Max([Date])-Min([Date])))) >=$(=Date(min([Date])-(Max([Date])-Min([Date]))))"}>}Value)

Hope it helps 

Thanks

Thanks and Regards
Kashyap.R
Nive
Partner - Contributor III
Partner - Contributor III
Author

Thanks kashap.. 

I got my ans after several tries..

=Sum({<date={"<=date(max(date)-count(distinct date)) >=date(min(date)-count(distinct date))"}>}value)