Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

ruthubarra
New Contributor II

Help with an expression

HI everyone.

I have a file with different dates (day/month/year) of 2011, 2012, 2013, and so on. and in the same file i have sales volumen. i want to build a chart that shows only data of on specific fix year despite of the year value the user chooses. Can some one be so kind to help me?

Thanks in advance.

1 Solution

Accepted Solutions
MVP
MVP

Re: Help with an expression

I think Sunny is right that your field is a date field, and this is your format: day/month/year ?

It would be good to create a calendar from your date field, using QlikSense date and time functions in your script, like

...

Year([Fecha Contable]) AS Year,

Month([Fecha Contable]) as Month,

...

Then what I suggested above should just work fine, if you clear selections on the fields the user selects in:

=Sum({<Year = {2013}, [Fecha Contable], Month >} Sales)

14 Replies
MVP
MVP

Re: Help with an expression

Try something like

=Sum({<Year = {2013}>} Sales)

MVP
MVP

Re: Help with an expression

I think looking at this document will be very informative to learn about set analysis

ruthubarra
New Contributor II

Re: Help with an expression

I have tried this one, but when i choose a different year it changes and i want to show always the same year

Thansk for your help

ruthubarra
New Contributor II

Re: Help with an expression

I will take a look indeed, thanks for your input

MVP
MVP

Re: Help with an expression

If you have what Stefan gave, the expression will never change based on a selection in Year field. It will always show 2013 numbers.

MVP
MVP

Re: Help with an expression

QV is case sensitive with regard to field names, so if I used {<Year = {2013}>}, your field name must exactely be Year.

If this is the case, and if you then only change selection in Year field, and not in any other field, the returned Sales value changes?

ruthubarra
New Contributor II

Re: Help with an expression

Thanks swuehl

The name of my "dates" field is [Fecha Contable] and i have put the following expression according to what you gave me. In this case Euros is the sales volumen field name.

Sum({<[Fecha Contable] = {2014}>} Euros), and changes when i choose in my App another year

i am doing something wrong?

Thanks again

martinpohl
Valued Contributor II

Re: Help with an expression

if you choose a year in Qlik Sense, the values are only calculated for the selected year -> automatically.

With set analysis you can for example calculate the sales from the previous year than the selected.

But by itself, Qlik Sense always caculates only the selected datas (year, region, artikle, customer)

Regards

MVP
MVP

Re: Help with an expression

If [Fecha Contable] is a date field, then this won't work. The format on LHS and RHS need to match.

You can try this:

Sum({<[Fecha Contable] = {"=Year([Fecha Contable]) = 2014"}>} Euros)

or this may be:

Sum({<[Fecha Contable] = {"=Year({1}[Fecha Contable]) = 2014"}>} Euros)

Sum({<[Fecha Contable] = {"=Year(Only({1}[Fecha Contable])) = 2014"}>} Euros)

Community Browser