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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
gerrycastellino
Creator III
Creator III

question on alternate states/addmonths in Year over Year calc

having a problem with my syntax below.

My default state is where I have the most recent month selected - see image.

I'm trying to go back 12 months to  grab a value from a year ago from my default state.

I have the below expr linked to alternate state which is not working.

=sum({< %Snapshot_Date = {"$(=addmonths($::%Snapshot_Date,-12,1))"} >} Headcount

What am I missing ?

Thankx !

Gerry.

1 Solution

Accepted Solutions
sunny_talwar

QlikView is case sensitive and you date field is called date1 and not Date1 (see the upper case D vs lower case d)..

This worked

=Sum({<emptype={'PT'}, date1 = {"$(=Date(AddMonths(Only({$} date1), -12), 'MM/DD/YYYY'))"}>}sales)

whereas this didn't

=Sum({<emptype={'PT'}, Date1 = {"$(=Date(AddMonths(Only({$} Date1), -12), 'MM/DD/YYYY'))"}>}sales)

View solution in original post

20 Replies
Anil_Babu_Samineni

Why are you looking expression? Instead of that we have always one selected value right. You can go for Alternate state as mention

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
gerrycastellino
Creator III
Creator III
Author

Anil:

You are not understanding the problem.

I'm trying to reference a date in default state going back 12 months,  in another alternate state.

It's a syntax issue I'm facing.

Gerry.

Anil_Babu_Samineni

Oh, I apologizes for that, Can you share application to look

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
gerrycastellino
Creator III
Creator III
Author

Hi anil

see attached.

gerrycastellino
Creator III
Creator III
Author

change the date to 4/30/16,  4/30/17.

avinashelite

So your object where your referring to the above expression has an alternate state ? if yes then it will be seeking the selection to be in the alternate state mode so this is the syntax

Function({[state_identifier1] <field_name2= [state_identifier2]::field_name3>}field_name)


in your expression I could not see the state 2

sum({< %Snapshot_Date = {"$(=addmonths($::%Snapshot_Date,-12,1))"} >} Headcount)

Anil_Babu_Samineni

Like this?

Capture.PNG

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
gerrycastellino
Creator III
Creator III
Author

HI Anil:

my source state is the default state $.

I'm assigning this in text box which is my "to" state, isn't it implied ?

Anil_Babu_Samineni

Do you follow the same Which Avinash provide the syntax in between the Operator <AlterNateState{

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