Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
flo2
Contributor III
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 ....

 

thanks for reading

if someone knows why in case

 

thanks a lot !

 

 

1 Solution

Accepted Solutions
marcus_sommer

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

- Marcus

View solution in original post

6 Replies
Or
MVP
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.

 

flo2
Contributor III
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 :

 

 

marcus_sommer

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

- Marcus

Or
MVP
MVP

Try changing your variable to

=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

 

Chanty4u
MVP
MVP

you can try with this?

Year={$(=MAX(Year))

or

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

 

PrashantSangle

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 🙂