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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Subtracting two variables.

Hi! I am new in Qlikview and I am having some troubles with variables.

I need to calculate the diference between the same variable evaluated in two differents dates. 

I think it would be something like: f(x) - f(x-1)

where f is the variable

         x= Year($(vMaxDate))

         x-1= =Year($(vMaxDate), -1)

This is the variable (which is also a division):

=$(vUsersLoggingCalls_Level2(Evolution ,Evolution))/$(vActiveProfileEmployees_Level2(Evolution ,Evolution))

Any idea?

Labels (1)
13 Replies
rubenmarin
MVP
MVP

Hi Esther, this variable has a lot of set analysis fixing the dates (one for each of the values if the 1st paramater), I think the best way is duplicating variables, one as it is for the current year (or maybe also needs a fix to keep only one year). The other one for the past year, and with the variables adapted to query the past year

$(=If('$1' = 'KPI', '$(vAdoptionTemporalSelection),[Growth MonthYear]=,[Date]={">=$(=$(vAdoptionStartRollingYear(KPI)))<=$(=$(vMaxDate))"}',

If('$1' = 'Cluster', '[Country]=,[Region]=,[Cluster]=p(),$(vAdoptionTemporalSelection),[Date]={">=$(vAdoptionMinDate($2))<=$(vAdoptionMaxDate($2))"}',

  If('$1' = 'EMEA', '[Country]=,[Cluster]=,[Region]=,$(vAdoptionTemporalSelection),[Date]={">=$(vAdoptionMinDate($2))<=$(vAdoptionMaxDate($2))"}',

  If('$1' = 'Evolution','$(vAdoptionTemporalSelection),[Growth Calendar Difference]={"0"},[Date]={">=$(=$(vAdoptionStartRollingYear(KPI)))<=$(=$(vMaxDate))"}',

    If('$1' = 'Region','[Territory Nominal Function]=,[Territory Nominal Franchise]=,[Territory Nominal F. District]=,[Territory Nominal F. Position]=,[Employee]=,$(vAdoptionResetRegion($3)),$(vAdoptionTemporalSelection),[Date]={">=$(vAdoptionMinDate($2))<=$(vAdoptionMaxDate($2))"}',

      If('$1' = 'L5','[Territory Nominal F. District]=,[Territory Nominal F. Position]=,[Employee]=,$(vAdoptionResetHighTerritory),$(vAdoptionTemporalSelection),[Date]={">=$(vAdoptionMinDate($2))<=$(vAdoptionMaxDate($2))"}',

        '$(vAdoptionTemporalSelection),[Date]={">=$(vAdoptionMinDate($2))<=$(vAdoptionMaxDate($2))"}')))))))

rubenmarin
MVP
MVP

To expand my answer: yes, it's difficult (and time-consuming) to modify this variables but maybe there is a possibility to add a paremeter to the vAdoptionMinDate, vAdoptionMaxDate and vAdoptionStartRollingYear variables (and by extension to vAdoptionRangeDate, vUsersLoggingCalls_Level2 and vActiveProfileEmployees_Level2; these ones should receive the parameter to pass it to the variables this variables contains).

Also changing $(vMaxDate) to a new parametrized variable that, using the same parameter as the previous variables, returns the Max date for Year($(vMaxDate)) or Year($(vMaxDate))-1, based on the parameter it receives.

Not applicable
Author

Thanks Ruben, I will try that

rubenmarin
MVP
MVP

Hope it will be possible to do it, I still don't know the contains of some of the variables used (and I will need some sample to test before been able give a confirmed answer) but if you achieved to go so far with these variables I'm sure you have enough knowledge to modify those.

Also a 2nd opinion would be nice before starting this difficult task, anyone in this thread sees another way for doing this?