Announcements
cancel
Showing results for
Did you mean:
Contributor III

## Problem with variable in set analysis

Hello,

I would like to have the current year which is inside a variable defined in Qlikview ( not in script ).

So i have a variable currentYear - Year(Date(Today(), 'MM/DD/YYYY'))  - Which so now returns me 2021.

And i would like to use it in my set analysis which is

num( (sum({<Mois={'déc.'}>*<Année={'=\$(LastYear)'}>} FinMois*POLO*alt([INTER],0)/100)) ,'# ##0,00',',',' ')

I tried before not to put in a variable but the solution there https://community.qlik.com/t5/QlikView-App-Dev/Include-the-current-year-in-Expression/td-p/1366252 didn't work i don't understand why...

I tried also this solution for variable but same : https://community.qlik.com/t5/New-to-Qlik-Sense/Using-variable-in-Set-Analysis/td-p/1059541 ....

if someone knows why in case

thanks a lot !

1 Solution

Accepted Solutions

Try it with ... Année={\$(=currentYear)} ...

- Marcus

6 Replies
MVP

Your variable is currentYear, but in your set analysis you're trying to use LastYear?

You also shouldn't need the equal sign in this case, I think - just {'\$(currentYear)'}

And this isn't actually important, but Year(Today()) is enough to get today's year, you don't need the extra date() layer with formatting.

Contributor III
Author

Thanks for response and informations 🙂 But it still doesn't work i don't understand why, i have this, the expression is shown as " OK" but the graph is empty.

num( (sum({<Mois={'déc.'}>*<Année={'\$(currentYear)'}>} FinMois*POLO*alt([INTER],0)/100)) ,'# ##0,00',',',' ')

When i replace the variable by 2021 it works, the graph is shown.

the variable is :

Try it with ... Année={\$(=currentYear)} ...

- Marcus

MVP

=Year(Date(Today())

With the equal sign at the start of it.

Or just use \$(=Year(Today())) without a variable.

For a better understanding of how variables work when expanded, have a look at henric's post here:

https://community.qlik.com/t5/Qlik-Design-Blog/The-Magic-of-Variables/ba-p/1465499

MVP

you can try with this?

Year={\$(=MAX(Year))

or

Year={\$(=Year(Today()))

Hi @flo2 ,

Can you provide some more information like what is variable Name, and why you use intersection * symbol?

Try below

in your variable definition, use "=" symbol, so  that it evaluate at variable definition only

like

Variable Name is CurrentYear

Definition =Year(Today())

Set Analysis

Sum({<Mois={'déc.'},Année={"\$(=CurrentYear)"}>}(FinMois*POLO*alt([INTER],0))/100)

if above not work then Please post screen shot it.

Thanks & Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Community Browser