Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

omodoshouses
New Contributor

Switch 2018 with an expression

Hello,

I have an issue which I cannot solve.

I have written the following code: Sum({$<start.autoCalendar.Year={2018}>}total_price). What I want is the total price for only 2018.

It actually works. However, I would like to replace 2018 with an expression which will be updating according to current year. In that way, when 2019 comes, this will become automatically 2019. I have tried to replace the 2018 with the following: year(today()), but I get no results. Do you have any recommendation?

1 Solution

Accepted Solutions
Digvijay_Singh
Honored Contributor III

Re: Switch 2018 with an expression

Try this -

Sum({$<start.autoCalendar.Year={$(=Year(today()))}>}total_price)

3 Replies
Digvijay_Singh
Honored Contributor III

Re: Switch 2018 with an expression

Try this -

Sum({$<start.autoCalendar.Year={$(=Year(today()))}>}total_price)

omodoshouses
New Contributor

Re: Switch 2018 with an expression

Thank you very much for your prompt reply. It does work indeed. May I ask another thing in case it is possible for you to answer. I would like to calculate the sales that I have had exactly a year ago for my previous year. So if I looked back at 26/02/2017, what is the amount of sales for 2017 that I would have seen?

The only way I have found out to do so is:

Sum({$<start.autoCalendar.Year={$(=Year(today())-1)},[created.autoCalendar.MonthsAgo]={12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30}>}total_price)

I guess that there should be a better way that just typing 12 month ago, 13 months ago  etc.

Is there any more general function for that?

Thank you in advance

Digvijay_Singh
Honored Contributor III

Re: Switch 2018 with an expression

Try this along with ‘year-1’expression-

Month = {$(=Month(today()))}

I didnt understand ur monthago condition.

In most of the cases date related functions help to identify the right

period, check addmonth function as well, its very useful to add/ subtract

months. Also monthstart function to check thing from start of the month.

Qlik help has good explanation about these.

Let me in case I can help u further if You are stuck somewhere. Thanks

On Mon, Feb 26, 2018 at 3:20 PM Omodos Houses <qcwebmaster@qlikview.com>

Community Browser