Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Variables and expressions

I have the following set expressions:

Num(sum({<[Date Dispensed]={">=$(=addmonths(MonthEnd(max([Date Dispensed]))+1,-12)) <=$(=max([Date Dispensed]))"}>}[MedAid Amount] + Shortfall), '$##,##0.00')


I have set the above as a variable named:     vSetMATCurrentDollar


and


Num(sum(Total{<[Date Dispensed]={">=$(=addmonths(MonthEnd(max([Date Dispensed]))+1,-12)) <=$(=max([Date Dispensed]))"}>}[MedAid Amount] + Shortfall), '$##,##0.00') 


which has set as a variable named:     vSetMATCurrentDollarTotal


In my application i now need to get the relative values of the two as follows:


$(vSetMATCurrentDollar)/$(vSetMATCurrentDollarTotal)


The above does not give the required results but if i use the two expressions as:

Num(sum({<[Date Dispensed]={">=$(=addmonths(MonthEnd(max([Date Dispensed]))+1,-12)) <=$(=max([Date Dispensed]))"}>}[MedAid Amount] + Shortfall), '$##,##0.00') / Num(sum(Total{<[Date Dispensed]={">=$(=addmonths(MonthEnd(max([Date Dispensed]))+1,-12)) <=$(=max([Date Dispensed]))"}>}[MedAid Amount] + Shortfall), '$##,##0.00')


The above gives the expected results.


Where am i getting it wrong in the use of variables above?


Regards. 

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Thank you very much.  I managed to locate my problem.  I had an = sign before the vSetMATCurrentDollarTotal expression when i set my variable.  This should not be there.

Regards.

View solution in original post

7 Replies
swuehl
MVP
MVP

Remove the label of your expression

$(vSetMATCurrentDollar)/$(vSetMATCurrentDollarTotal)

in a straight table, then hover with the mouse over the expression label in the chart, you should see the expression with all dollar sign expansions expanded. Do you see

Num(sum({<[Date Dispensed]={">=$(=addmonths(MonthEnd(max([Date Dispensed]))+1,-12)) <=$(=max([Date Dispensed]))"}>}[MedAid Amount] + Shortfall), '$##,##0.00') /Num(sum(Total{<[Date Dispensed]={">=$(=addmonths(MonthEnd(max([Date Dispensed]))+1,-12)) <=$(=max([Date Dispensed]))"}>}[MedAid Amount] + Shortfall), '$##,##0.00')



or something else?

maxgro
MVP
MVP

do the variables work when you use them in 2 different expressions (2 columns)?

I tried in a .qvw and the variables work, see attachment.

sunny_talwar

I think def. try both the variables separately as two expressions, but also see what do you get when you use the variables without the dollar sign expansion:

vSetMATCurrentDollar/vSetMATCurrentDollarTotal

Anonymous
Not applicable
Author

Thank you very much.  I managed to locate my problem.  I had an = sign before the vSetMATCurrentDollarTotal expression when i set my variable.  This should not be there.

Regards.

Anonymous
Not applicable
Author

Thanks Maxgro, see my post above.

Anonymous
Not applicable
Author

Hi Sunny, thank you very much, see my post above, managed to locate my mistake

sunny_talwar

Awesome, I am glad you were able to figure it out