Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
jimgibson
New Contributor

Substitute a variable into an expression

 

In what I have below, how do I substitute the value of vCHMetricToUse into eCHMetricEncounterCNT and eCHMetricMedian ?

 

Set vCHMetricToUse=A-AD;
Set eCHMetricEncounterCNT= Count([PatientEncounterID]) - NullCount([A-AD]);
Set eCHMetricMedian=Median([A-AD]);
Set vCHMetric=Door to Admit Throughput; 

 

Thanks in Advance

1 Solution

Accepted Solutions
MVP
MVP

Re: Substitute a variable into an expression

If you want the replacement to happen when the script executes, you can use a dollar sign expansion:

Set vCHMetricToUse=A-AD;

Set eCHMetricEncounterCNT= Count([PatientEncounterID]) - NullCount([$(vCHMetricToUse)]);

Set eCHMetricMedian=Median([$(vCHMetricToUse)]);

Set vCHMetric=Door to Admit Throughput;

If you need the replacement to happen in the front end (i.e. you want to change vCHMetricToUse also in the front end, try

Set vCHMetricToUse=A-AD;

LET eCHMetricEncounterCNT= 'Count([PatientEncounterID]) - NullCount([$' & '(vCHMetricToUse)])';

LET eCHMetricMedian='Median([' & '$(vCHMetricToUse)])';

Set vCHMetric=Door to Admit Throughput;

OR

Set vCHMetricToUse=A-AD;

LET eCHMetricEncounterCNT= Replace('Count([PatientEncounterID]) - NullCount([@(vCHMetricToUse)])','@','$');

LET eCHMetricMedian= Replace('Median([@(vCHMetricToUse)])','@','$');

Set vCHMetric=Door to Admit Throughput;

The Magic of Dollar Expansions

The Magic of Variables

Stop Dollar Sign Expansion in the script (Escape Character ??? )

3 Replies

Re: Substitute a variable into an expression

May be this:

Set vCHMetricToUse=A-AD;
Set eCHMetricEncounterCNT= Count([PatientEncounterID]) - NullCount(vCHMetricToUse);
Set eCHMetricMedian=Median(vCHMetricToUse);
Set vCHMetric=Door to Admit Throughput;

jimgibson
New Contributor

Re: Substitute a variable into an expression

That did not work or at least when I tried to use it by setting the text in a text object as = $(eCHMetricMedian) I get nothing.

MVP
MVP

Re: Substitute a variable into an expression

If you want the replacement to happen when the script executes, you can use a dollar sign expansion:

Set vCHMetricToUse=A-AD;

Set eCHMetricEncounterCNT= Count([PatientEncounterID]) - NullCount([$(vCHMetricToUse)]);

Set eCHMetricMedian=Median([$(vCHMetricToUse)]);

Set vCHMetric=Door to Admit Throughput;

If you need the replacement to happen in the front end (i.e. you want to change vCHMetricToUse also in the front end, try

Set vCHMetricToUse=A-AD;

LET eCHMetricEncounterCNT= 'Count([PatientEncounterID]) - NullCount([$' & '(vCHMetricToUse)])';

LET eCHMetricMedian='Median([' & '$(vCHMetricToUse)])';

Set vCHMetric=Door to Admit Throughput;

OR

Set vCHMetricToUse=A-AD;

LET eCHMetricEncounterCNT= Replace('Count([PatientEncounterID]) - NullCount([@(vCHMetricToUse)])','@','$');

LET eCHMetricMedian= Replace('Median([@(vCHMetricToUse)])','@','$');

Set vCHMetric=Door to Admit Throughput;

The Magic of Dollar Expansions

The Magic of Variables

Stop Dollar Sign Expansion in the script (Escape Character ??? )