Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Username
Contributor
Contributor

Last year calculations

Hello everyone,

I have an income statement in my Qlik Sense application.

I am able to calculate the percentage of the row value related to the revenue. Now i am trying to calculate the same percentage for last year but haven't been successful.

Here is the code for this year that works:

sum(Test11) / sum(TOTAL {$<[ReportLineDescription] = {'Revenue'}>} Test11)

So what is wrong with this script:

(sum({$<Vvvv = {$(=Only(Vvvv)-1)}>} Test11)) / sum(TOTAL {$<[ReportLineDescription] = {'Revenue'}>}{$<Vvvv = {$(=Only(Vvvv)-1)}>}Test11) 

 

1 Solution

Accepted Solutions
pradosh_thakur
Master II
Master II

if vvv is year then 

(sum({$<Vvvv = {"$(=year(today())-1)"}>} Test11)) / sum(TOTAL {$<[ReportLineDescription] = {'Revenue'},Vvvv = {"$(=year(today())-1)"}>}Test11) 
Learning never stops.

View solution in original post

5 Replies
arulsettu
Master III
Master III

What is Vvvv ?

is that date field?

do you have year field?

Username
Contributor
Contributor
Author

Ohh, sorry the explanation was incomplete. The Vvvv = year

pradosh_thakur
Master II
Master II

Try something similar

 

Assuming you have a date field date1, you have to replace date1 with your date field 

 

sum({<date1={"=Year(date1)=year(today())-1"}>}Test11) / sum(TOTAL {$<[ReportLineDescription] = {'Revenue'},date1={"=Year(date1)=year(today())-1"}>} Test11)

Learning never stops.
pradosh_thakur
Master II
Master II

if vvv is year then 

(sum({$<Vvvv = {"$(=year(today())-1)"}>} Test11)) / sum(TOTAL {$<[ReportLineDescription] = {'Revenue'},Vvvv = {"$(=year(today())-1)"}>}Test11) 
Learning never stops.
arulsettu
Master III
Master III

Maybe like this

 

(sum({$<Vvvv = {$(=max(Vvvv)-1)}>} Test11)) / sum(TOTAL {$<[ReportLineDescription] = {'Revenue'}>}{$<Vvvv = {$(=max(Vvvv)-1)}>}Test11)