# Qlik Sense App Development

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
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

Tags (1)
1 Solution

Accepted Solutions
Highlighted
MVP & Luminary

## 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.

talk is cheap, supply exceeds demand
5 Replies
Highlighted
MVP & Luminary

## 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.

talk is cheap, supply exceeds demand
Highlighted
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

Highlighted
Valued Contributor III

## Re: Can a variable be formatted as a number?

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

Highlighted
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.

Highlighted
MVP & Luminary

## Re: Can a variable be formatted as a number?

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

talk is cheap, supply exceeds demand