Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to use get_current_feild function for selection of date range in calender

Hi

I want if I select date range from 1st jan 2014 till 2nd feb 2016 then the data 2016 should become current year and date 2014 should become previous year in chart so for that how to declare variable vstart (starting date in calender) and variable vend(ending date in calender)

also what will be the corresponding expressions for both previous year and current year sales in charts finalsales.png

i have used these expressions  for current year and previous year

previous year

=num(sum(if(Sold_Date >=vstart and Sold_Date<= vend, [inv value]/Sales_INR_Unit)),'#,##0.0')

current year

=num(sum(if(Sold_Date >=vstart and Sold_Date<= vend ,[inv value]/Sales_INR_Unit)),'#,##0.0')

but both previous year and current year are giving same values

so please suggest the appropriate expressions ?

1 Solution

Accepted Solutions
Anil_Babu_Samineni

Try this for Prev year and show the same image?

=num(sum(if(Sold_Date >=AddYears(vstart, -1) and Sold_Date<= AddYears(vend, -1), [inv value]/Sales_INR_Unit)),'#,##0.0')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

9 Replies
Anil_Babu_Samineni

Try this?

=num(sum(if(Sold_Date >=AddYears(vstart,1) and Sold_Date<= vend, [inv value]/Sales_INR_Unit)),'#,##0.0')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

is this expression used for previous year?

Anil_Babu_Samineni

s

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

what about current year? that wil remain same?

Anonymous
Not applicable
Author

i have declared variable as vstart=getcurrentselection(sold_date)

is this correct?

Anil_Babu_Samineni

What you shown in line is correct to me? Are you facing any challenge. If you want to test them use Text object to understand how and what it returned?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

yes i am facing one problem if i am using date range from 1st jan 2017 to 15th jan 2017 the data in previous year is displayed as o and current year has got some sales.

but i want on selecting date 1st jan 2017 to 15th jan 2017 under previous year the value should not be displayed as 0 rather it should have value one year prior to current year finalsales.png

Anil_Babu_Samineni

Try this for Prev year and show the same image?

=num(sum(if(Sold_Date >=AddYears(vstart, -1) and Sold_Date<= AddYears(vend, -1), [inv value]/Sales_INR_Unit)),'#,##0.0')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anil_Babu_Samineni

I believe you got hat you need, So i would request you to do your job to close this thread by flag "Correct Answer" for next lander users can easy understand the same situation..

Best,

Anil

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful