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: 
jimgibson
Contributor
Contributor

Using expression in Inline table

I am loading the following INLINE table

LOAD * INLINE [
Metric, ShortDSC, LongDSC, SortOrder, MedianCalc
A-AD, Door to Admit, median of Door to Admit, 1, Median('A-AD')
A-OF, Door to On-Floor, median of On-floor, 3, Median('A-OF')
A-RD, Door to Ready for Discharge, median door to discharge, 2, Median('A-RD')
]
;

This loads without errors but when I try to load the Expression into the Definition box of a straight table as $(MedianCalc) I do not get any results.  Normally to use the expression I have to use Median([A-AD]) however the INLINE does not like the [] so I replaced them with '' and it loads.

Any ideas on what I am doing wrong?

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

Hi Jim,

Try this expression..

$(=concat('if(Metric=' & chr(39) & Metric & chr(39) & ',Median({1}[' & Metric & '])', ',') & concat(right(Metric&')',1)))

View solution in original post

24 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

You can replace the square brackets on the inline using double quotes. Then you can use square brackets in the inline.

LOAD * Inline

"

...

";

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

Are you trying to reference the field in the $ expansion? Do you want to evaluate it as an expression? is A-AD a field in your model?

I am not sure what you mean by the "definition box".

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Also note that in a straight table this will only work if you don't use any of the other INLINE table field as a dimension. $-sign substitution will be performed only once for the entire table, not row-by-row.

You can use the Metric field as a list box with Always-One-Selected enabled, to select a single expression to be displayed.

settu_periasamy
Master III
Master III

Hi,

May be try   =$(=MedianCalc)

Peter_Cammaert
Partner - Champion III
Partner - Champion III

IMHO that won't work with MedianCalc being a field name. Because as a first step the expression will expand to:

=$(Median([A-AD]))  // doesn't work as there is no variable with that name

if a single Metric is active, or to

=$() // probably generates an error

if multiple Metrics are selected.

Jim will have to use an intermediate variable that first upon evaluation stores the value of MedianCalc and only then does the $-sign substitution.

In Variable Overview, define a variable called vMetricExpression and assign the following as value:

=MedianCalc

Then in the expression field where the dynamic expression should provide results, put:

=$(vMetricExpression)

Best,

Peter

settu_periasamy
Master III
Master III

Thank you Peter ..

jimgibson
Contributor
Contributor
Author

Peter,

I tried this but I still do not get any results.  See the attached PDF.  The third column in the straight table does not give any results.

Any ideas?

settu_periasamy
Master III
Master III

Can you share the Sample Qvw?

ramoncova06
Partner - Specialist III
Partner - Specialist III

if you say that the expression works ok with brackets, then just replace where you add the brackets to the field, you can do this with a preceding load

load

Metric,

ShortDSC,

LongDSC,

SortOrder,

'Median(['&MedianCalc&'])' as MedianCalc;

LOAD * INLINE [

Metric, ShortDSC, LongDSC, SortOrder, MedianCalc

A-AD, Door to Admit, median of Door to Admit, 1, A-AD

A-OF, Door to On-Floor, median of On-floor, 3, A-OF

A-RD, Door to Ready for Discharge, median door to discharge, 2, A-RD

];