Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Partner
Partner

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
Highlighted
Partner
Partner

Re: Find Previous date range values from selected date range

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
Highlighted
Partner
Partner

Re: Find Previous date range values from selected date range

Hi

try this

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

Hope it helps 

Thanks

Highlighted
Partner
Partner

Re: Find Previous date range values from selected date range

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