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: 
Not applicable

How to use a field value as *logic* in an expression?

I want to have "table-driven" logic in a config file.  So, for example, I load a file with entries as follows:

RecordIDComputeLogicVarName
1[field1] = [field2]EqualVar
2[field1]=[field[2] or [field1]=[field3]OrVar
3 ...[field1]<>[[field4]NotVar

Assume that [field-n] values are populated earlier.

Then, I want to have a table list the values of [EqualVar], [OrVar], and [NotVar], which would have an expression like:

     if([ComputeLogic], 1, 0)

5 Replies
Not applicable
Author

Hi,

I'm not sure understand but you can try to use match or wildmatch function.

Ex. If( Match(Field1,Field2), 1, 0)

Best regards.

Not applicable
Author

Thanks for the quick response.

Yes, I am familiar with Match.

However, the actual logic conditions are potentially complex, and Match only applies the ‘=’ operation between fields. Also, the logic expression might contain many fields, not just 2.

That is why I want dynamic evaluation of the text of any logical expression stored as its own field.

The functionality I want is equivalent to eval() in javascript, if you are familiar with that language. A string parameter passed to eval will be parsed and evaluated as if it were actual javascript code, which is what I need here.

Todd Tieger

Senior R&D Architect

Deloitte Touche Tohmatsu

Tel: 609-806-7259

ttieger@deloitte.com<mailto:ttieger@deloitte.com>

www.deloitte.com<http://www.deloitte.com/>

This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and any disclosure, copying, or distribution of this message, or the taking of any action based on it, by you is strictly prohibited.

v.E.1

jerem1234
Specialist II
Specialist II

There is only a few things that you can do that I know of. You'll have to use a pick(match()) statement with a $(=concat()) like:

pick(match(Category, 'A', 'B', 'C'), $(=concat(distinct Compute, ',', Order)))

or you can create variables like:

pick(match(Category, 'A', 'B', 'C'), $(vBoolean1), $(vBoolean2), $(vBoolean3))

and have the variables store the boolean expressions.

However, if there is a large amount of data, performance will be poor.

You may move it to the script to perform, but that requires a little finesse. I put in an example of all three in the attached dashboard (concat, variables, script).

Hope this helps!

Not applicable
Author

Sorry for the delay in responding, but I appreciate your help on this.

Todd Tieger

Senior R&D Architect

Deloitte Touche Tohmatsu

Tel: 609-806-7259

ttieger@deloitte.com<mailto:ttieger@deloitte.com>

www.deloitte.com<http://www.deloitte.com/>

This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and any disclosure, copying, or distribution of this message, or the taking of any action based on it, by you is strictly prohibited.

v.E.1

Not applicable
Author

Thank you – and sorry for the delay in responding.

Todd Tieger

Senior R&D Architect

Deloitte Touche Tohmatsu

Tel: 609-806-7259

ttieger@deloitte.com<mailto:ttieger@deloitte.com>

www.deloitte.com<http://www.deloitte.com/>

This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and any disclosure, copying, or distribution of this message, or the taking of any action based on it, by you is strictly prohibited.

v.E.1