Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

beck110979
Valued Contributor III

Current Year vs Sum of previuos Year

Hi Folks,

i have a question: my table does look like:

Year, Turnover, Company

2018, 500, A

2017, 400, B

2016, 300, C

i am using this expression to show the turnover of current year:

Sum({<Year = {"$(=Year(today()))"}>}Turnover)

my question is:

how can i show via set expression the sum of previous year (2017 + 2016 = 400 + 300)

i want to show the comparison like:

2018,   All Previous Years

500,             700

does anybody have any idea?

Thanks a lot

Beck

1 Solution

Accepted Solutions

Re: Current Year vs Sum of previuos Year

My bad, I missed a closing double quote

Sum(TOTAL {<Year = {"$(='<' & Year(Today()))"}>} Turnover)

6 Replies

Re: Current Year vs Sum of previuos Year

May be this

Sum(TOTAL {<Year = {"$(='<' & Year(Today()))}>} Turnover)

beck110979
Valued Contributor III

Re: Current Year vs Sum of previuos Year

Hi Sunny,

thanks a lot for your help, i tried to implement that way, but it does not work

Beck

Re: Current Year vs Sum of previuos Year

My bad, I missed a closing double quote

Sum(TOTAL {<Year = {"$(='<' & Year(Today()))"}>} Turnover)

beck110979
Valued Contributor III

Re: Current Year vs Sum of previuos Year

Sunny thanks a lot for your time and help

qliksensejp
New Contributor II

Re: Current Year vs Sum of previuos Year

Hello good afternoon.


I was testing the problem you mentioned, I believe the problem is in the field for the year, I made a modification and added the date field of issue in the location of the year column.


EMISSION, Turnover, Company

05/05/2016, 500, A

05/05/2017, 400, B

05/05/2018, 300, C


Then I loaded the file.


LOAD

     EMISSION,

     Date (EMISSION, 'YYYY') the YEAR,

     Turnover,

     Company

FROM

(ooxml, embedded labels, table is Plan1);


I used a text object with the following expression:

=num(sum({$<[ANO]={"$(=Year(Today())-1)"}>} Turnover)+sum({$<[ANO]={"$(=Year(Today()))"}>} Turnover),'#.#00,00')


If you create a column in the expression tab:

sum ({$ <[YEAR] = {" $ (= Year (Today ())-1) "}>} Turnover) + sum ({$ <[YEAR] = {" $ (= Year (Today ()) ) "}>} Turnover)


And it also works with:


= num (sum (TOTAL Turnover), '#. # 00,00')


But for the latter you would need a filter over the years, if you select one or more years, the sum follows the selection.


Hope this helps. Sorry if English is not perfect, I used the google translate.

beck110979
Valued Contributor III

Re: Current Year vs Sum of previuos Year

Hey Rildo, thanks a lot for your help and time,

your way is very informative for me. Many Thanks

Community Browser