Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
deepika_gohil
Contributor
Contributor

Variable creation for past period

Hi,

I have a Bar graph where I have to show historical data for this I was planning to create 2 variables which show past period start date and end date. 

I have a date range from which the user can pick a start and end date to see the result. Below is the screenshot of my requirement.  

Capture.JPG

for current trend line chart I am using below mentioned formula

num(Sum({$<[Posting Date]={">=$(=vCYStartDate)<=$(=vCYEndDate)"} >} Revenue),'####.##')

Same formulas I am planning to use for historic trend but This 2 varialbes wont work.

CYStartDate - hard coded - 01/04/2018

CY end date - 31/12/2020

Request you to please help me with the formulas for past period variables.

I am trying with below but isnt working

VPyend date =date(addyears(max([Posting Date]), -1), 'DD/MM/YYYY')

when I try calling this variable in text and object but its not working.

vPYstart date - =date(MakeDate( subfield(vPYEndDate,'/',3),subfield(vCYStartDate,'/',2)),'DD/MM/YYYY')

Request you to please suggest...

Labels (2)
2 Replies
deepika_gohil
Contributor
Contributor
Author

Hi Sunny,

I have a Bar graph where I have to show historical data for this I was planning to create 2 variables which show past period start date and end date. 

I have a date range from which the user can pick a start and end date to see the result. Below is the screenshot of my requirement.  

Capture.JPG

for current trend line chart I am using below mentioned formula

num(Sum({$<[Posting Date]={">=$(=vCYStartDate)<=$(=vCYEndDate)"} >} Revenue),'####.##')

Same formulas I am planning to use for historic trend but This 2 varialbes wont work.

CYStartDate - hard coded - 01/04/2018

CY end date - 31/12/2020

Request you to please help me with the formulas for past period variables.

I am trying with below but isnt working

VPyend date =date(addyears(max([Posting Date]), -1), 'DD/MM/YYYY')

when I try calling this variable in text and object but its not working.

vPYstart date - =date(MakeDate( subfield(vPYEndDate,'/',3),subfield(vCYStartDate,'/',2)),'DD/MM/YYYY')

Request you to please suggest...

Anil_Babu_Samineni
MVP
MVP

If u want some person need help You can always tag them using @ option. This will notify to user.

For now, I've done for you @sunny_talwar 

BTW, What r u trying to achieve here using this expression?

num(Sum({$<[Posting Date]={">=$(=vCYStartDate)<=$(=vCYEndDate)"} >} Revenue),'####.##')

Those variables not working? If so, Can you simplify like this?

num(Sum({$<[Posting Date]={">=$(=Date(AddYears(vCYStartDate,-1)),'Same as Posting Date')<=$(=Date(AddYears(vCYEndDate,-1)),'Same as Posting Date')"} >} Revenue),'####.##')

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