Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sakshikaul
Creator II
Creator II

date functionality

Hi,

I have a query, I want to compare the sales for a current year with sales 10 days prior to current year

Here in the below image when user selects an event , corresponding date for that particular event and corresponding days for comparison 

for eg as shown in below image users select event as Diwali, date as 10/10/2018

no of days for comparison =9

so Date selected for comparing is calculated based on following 

Date selected by user(10/10/2018 )- no of days for comparison (9) so  'Date selected for comparison '=1/10/2018 

so now I have to compare between the given range last year date ie 1/10/2018  and current year date 10/10/2018,

so this is working fine only if I am selecting no of days for  comparison as 1,2,3,4,5,6,7,8,9 but if I am selecting  no of comparison days as 10 then its not working  because here date selected for comparison will be 30/09/2018 so this means here the month will be changed .

This is working fineThis is working fine

this is not working finethis is not working fine

 

27 Replies
pradosh_thakur
Master II
Master II

use the below set analysis in your expression

lets say your date field is datefield and v_days contain the no of days

{<datefield={"<=$(=max(datefield)) >=$(adddays(max(datefield),-$(v_days)))"}>}
Learning never stops.
sakshikaul
Creator II
Creator II
Author

You mean this?

=sum({< Sold_Date = {"<=$(=max(Sold_date)) >=$(adddays(max(Sold_date),-$(compday)))"}>} quantity_sold)

 

shiveshsingh
Master
Master

sum({< Sold_Date = {">=$(=max(Date))<=$(=Date(max(date)-vNo))"} >} quantity_sold)
- sum({< Sold_Date = {">=$(=max(Date))<=$(=Date(max(date)-vNo))"} >}quantity_returns)

 

where vNO is the number of days entered.

sakshikaul
Creator II
Creator II
Author

 

Hi,

I am using following expression but its giving me no result

sum({< Sold_Date = {">=$(=max(Date))<=$(=Date(max(date)- compday)"} >} quantity_sold)
- sum({< Sold_Date = {">=$(=max(Date))<=$(=Date(max(date)- compday)"} >}quantity_returns)

 

pradosh_thakur
Master II
Master II

sum({< Sold_Date = {"<=$(=max(Date))>=$(=Date(max(date)- compday)"} >} quantity_sold)
- sum({< Sold_Date = {"<=$(=max(Date))>=$(=Date(max(date)- compday)"} >}quantity_returns)

you and @shiveshsingh  have written >= max date and <= maxdate-10 which is not what you want. ..Try the above. i have altered it.

Learning never stops.
sakshikaul
Creator II
Creator II
Author

now I have tried what  you said still not working

sum({< Sold_Date = {"<=$(=max(lastDate))>=$(=Date(max(lastDate)- compday)"} >} quantity_sold)
- sum({< Sold_Date = {"<=$(=max(lastDate))>=$(=Date(max(lastDate)- compday)"} >}quantity_returns)

 

 

Here lastDate is labelled(caption ) as Date in list box

pradosh_thakur
Master II
Master II

what do you see when you use =compday in a text box

and what do you see when you use    =$(Date(max(lastDate)- compday) in a text box.

Learning never stops.
sakshikaul
Creator II
Creator II
Author

paint.png

pradosh_thakur
Master II
Master II

use thsi 

Date(max(lastDate)- compday)

 

select the event please , then see

Learning never stops.
sakshikaul
Creator II
Creator II
Author

paint.png