Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
ShellyG
Creator
Creator

Variable in expression syntax

Hi everyone, 

I need help with replacing a field name with a variable name in an expression. 

Basically, I have the below for example:

sum({<COMPLETED={'COMPLETED'}>}TICKETS)/sum({1}total <CALENDAR_MONTH> TICKET_VOLUME)

How should I rewrite the expression in order to replace 'CALENDAR_MONTH' with a variable called vMonths? 

I tried <vMonths> and <=$(vMonths)> but it doesn't seem to work properly. 

Thanks in advance!

Labels (2)
1 Solution

Accepted Solutions
Kushal_Chawda

@ShellyG   make sure that your expression in variable should have "="  which basically should evaluate first So add "=" if you don't have like below

=pick(match([~VIEWBY6_NAME], 'Fiscal', 'Calendar')
,'FISCAL_MONTH'
,'CALENDAR_MONTH')

Now you can try below expression

sum({<COMPLETED={'COMPLETED'}>}TICKETS)/sum({1}total <$(vMonth)> TICKET_VOLUME)

If it still doesn't work then try below expression without using variable

sum({<COMPLETED={'COMPLETED'}>}TICKETS)/

pick(match([~VIEWBY6_NAME], 'Fiscal', 'Calendar'),

sum({1}total <FISCAL_MONTH> TICKET_VOLUME),

sum({1}total <CALENDAR_MONTH> TICKET_VOLUME))

View solution in original post

8 Replies
Usama
Creator
Creator

Hi,

try below:
'$(vMonths)' use this in place of field name.

Thanks

From Nothing - To Something - To Everything
PrashantSangle

share variable definition..

 

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
ShellyG
Creator
Creator
Author

Hi Prashant,

This is the definition:

pick(match([~VIEWBY6_NAME], 'Fiscal', 'Calendar')
,FISCAL_MONTH
,CALENDAR_MONTH)

VIEWBY6_NAME is referring to an inline table that I made. Afterwards in the app I have created a button where you can select between fiscal and calendar with always one of the two selected. 

ShellyG
Creator
Creator
Author

I tried this but it didn't work with my expression... 

avinashelite

Try like this :
pick(match([~VIEWBY6_NAME], 'Fiscal', 'Calendar')
,'FISCAL_MONTH'
,'CALENDAR_MONTH')

ShellyG
Creator
Creator
Author

Still nothing 😞

Kushal_Chawda

@ShellyG   make sure that your expression in variable should have "="  which basically should evaluate first So add "=" if you don't have like below

=pick(match([~VIEWBY6_NAME], 'Fiscal', 'Calendar')
,'FISCAL_MONTH'
,'CALENDAR_MONTH')

Now you can try below expression

sum({<COMPLETED={'COMPLETED'}>}TICKETS)/sum({1}total <$(vMonth)> TICKET_VOLUME)

If it still doesn't work then try below expression without using variable

sum({<COMPLETED={'COMPLETED'}>}TICKETS)/

pick(match([~VIEWBY6_NAME], 'Fiscal', 'Calendar'),

sum({1}total <FISCAL_MONTH> TICKET_VOLUME),

sum({1}total <CALENDAR_MONTH> TICKET_VOLUME))

ShellyG
Creator
Creator
Author

Hi Kush,

Thank you for your idea,  it works 🙂

Best Regards, 

Shelly