Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator II
Creator II

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
Highlighted

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')

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

9 Replies
Highlighted

Try this?

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Creator II
Creator II

is this expression used for previous year?

Highlighted

s

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Creator II
Creator II

what about current year? that wil remain same?

Highlighted
Creator II
Creator II

i have declared variable as vstart=getcurrentselection(sold_date)

is this correct?

Highlighted

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?

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Creator II
Creator II

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

Highlighted

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')

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

Highlighted

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)