Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variables

Hello,

I have a report which uses variables to make calculations (based on time). All of a sudden, certain variables have stopped working (i.e. calculating the appropriate figues, im now getting a 0 value, as opposed to the correct figure)

These variables are as follows:

    

- vCurrentMth1 = max(Date_MonthYear)  - and this calculates the correct month (May 2011) and the correct figure, so everything is ok here.

However...

- vCurrentMth12 = date(addmonths(date(today()-30,'MMM-YYYY'),-12),'MMM-YYYY') - this calculates the figures for May 2010 (12 months previous) and      im getting a 0 value for this, but it worked ok before   (incidently, when i put this variable in a text object, the correct month is displayed - "May 2010")

- vCurrentMthTwelve = date(addmonths(Date_MonthYear,-12),'MMM-YYYY')  - my report displays a 0 value for this also...

Does anyone have any ideas as to why im receiving these values? Any help would be greatly appreciated.

Thanks

7 Replies
Anonymous
Not applicable
Author

I don't see anything wrong.

All options works fine with me.

Can you share your document so we can take a closer look?

Not applicable
Author

Theres alot of "sensitive" information on the doc, I dont think my boss would be too pleased if i posted it online!

Hopefully I'll find some solution...

Miguel_Angel_Baeyens

Hello Brian,

Is it possible that you are using those values in a set analysis or conditional without quoting them? Since the results are non numeric, they might be quoted. Not as well that QlikView is case sensitive, and "May" is not the same as "may", and the blanks are not equal to the "-" sign you are using in some of your code above in the date formatting.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

IAMDV
Luminary Alumni
Luminary Alumni

I agree with Dennis, everything looks right. I understand that you can't post the sample document because of confidentiality. I am assuming that you understand the variable behaviour with "=" and without "=" while defining the variables.

I mean when you use the equal to sign "=" beginning of your variable expression then the behaviour is different without using "=". If you use the "=" at the beginning of your expression while defining the variable then QV will evaluate the variable only once for entire document compared to each dimension while not using "=" at the beginning of the expression. I mean if you dont use "=" at the beginning it is dollar sign expansion.

I am just guessing a possiblity of what could be an issue. I am might be wrong, but this is just a guess.

Cheers - DV

Anonymous
Not applicable
Author

I Understand, you have to be careful with that.

Can you maybe reproduce the problem in an empty/new Qlikview document.

Or at least show waht you mean with :"im getting a 0 value for this".

Where do you get this and how are you using your variable?

gandalfgray
Specialist II
Specialist II

Hi Brian

Try

vCurrentMth12 = num(date(addmonths(date(today()-30,'MMM-YYYY'),-12),'MMM-YYYY'))

Not applicable
Author

Its working correctly now. Basically I have 2 list boxes, one for month and another for year. I think the issue was with the year listbox, when I deselected it the correct figures appeared on my report. I still have a bit of work to do but I think the main issue has been pretty much resolved, thanks for your help guys