Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

jtay
New Contributor III

Can a variable be formatted as a number?

I have a field in my Master Calendar called Month Sequence.

(,AutoNumber( year(TempDate)&month(TempDate)) as MonthSequence)

It is generated as a number field.

In a KPI, Max(MonthSequence)   show 142  which is correct.

Also in a KPI   Max(MonthSequence)-12   shows 130      I can perform calculations on that number.

I’ve defined the variable $(vMaxMonSeq) as Max(MonthSequence)    adding the variable to a KPI shows a value of  142

But, I can’t do any calculations with it.

I've tried setting it up as a number with num(), num#(), and with num(num# (Max(MonthSequence)))

I can change the variable definition to Max(MonthSequcne)-12   and it will show correctly.

Do all variables come in as text?   What are my options?


Nothing seems to work. 

Thank you

1 Solution

Accepted Solutions

Re: Can a variable be formatted as a number?

But, I can’t do any calculations with it.

Can you give an example of a calculation you're trying to do. An example QS app would help.

5 Replies

Re: Can a variable be formatted as a number?

But, I can’t do any calculations with it.

Can you give an example of a calculation you're trying to do. An example QS app would help.

jtay
New Contributor III

Re: Can a variable be formatted as a number?

I will work on getting an example...

but the calculation I'm trying is simply subtracting 12. 

$(vMaxMonSeq)-12

roharoha
Valued Contributor III

Re: Can a variable be formatted as a number?

you could try $(#vMaxMonSeq) for getting the number...

jtay
New Contributor III

Re: Can a variable be formatted as a number?

Hi Gysbert

I got an example app ready to post and was adding the KPIs with the calculation examples to a sheet. 

I created the variable.  I added two KPIs without the variable and two more with the variable.

They all worked correctly.  (scratches head and wonders why...)

I copied everything into my main app and now things are calculating correctly there too.

Problem solved, but I don't know why it wasn't working before.

I guess the exercise of starting over helped.  thanks you for the suggestion.

Re: Can a variable be formatted as a number?

You're welcome. Glad you got it sorted now.