Qlik Community

Qlik Sense App Development

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

Highlighted
acbishop2
Contributor

Variables not working together in expression.

Hi All,

I've noticed before that when doing arithmetic with variables, I often need to put parentheses around them, but that's not working this time. Here's the deal:

I have 3 Variables:

1) vCurrentMonthLeadGoal - contains the lead goal for this month.

2) vCurrentMonthWorkDays - contains the number of workdays in this month.

3) vMTDWorkDays - contains the number of workdays from the beginning of this month to today.

Each of the above variables works on its own. However, when I try to combine the three to create a 4th variable, I run into a problem. My fourth variable is meant to calculate today's lead "target", which is essentially just where we should be today to meet this month's goal. The formula is as follows:

($(vCurrentMonthLeadGoal))

/

($(vCurrentMonthWorkDays))

*

($(vMTDWorkDays))

This just gives me a "-".  Any solution?

Thanks in advance for the help.

2 Replies
acbishop2
Contributor

Re: Variables not working together in expression.

EDIT:

The vCurrentMonthLeadGoal is made up of a collection of sums:

Sum(Expression1)

+

Sum(Expression2)

+

Sum(Expression3)

I took the ceiling of this expression, and everything is working fine now:

Ceil(

Sum(Expression1)

+

Sum(Expression2)

+

Sum(Expression3)

)

That said, I'd still like to know why it behaves this way. If anyone could enlighten me, I would appreciate it.

MVP & Luminary
MVP & Luminary

Re: Variables not working together in expression.

I think the reason is your default number-formatting which probably used the comma as decimal delimiter. This means vCurrentMonthLeadGoal returned probably something like 100,50 which is fine if applied anywhere as a single-expression but is invalid as part of further calculations because it regards the comma than as a parameter delimiter.

To solve this you could change the default formatting (in the script-variables in script-tab main but be careful - it might have side-effects to other interpretations/calculations in script and UI of your application) or you used a formatting like:

num(($(vCurrentMonthLeadGoal)), '# ##0.##', '.', ' ')

- Marcus