Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression Syntax with multiple variables

Hi,

I'm struggling with quite a basic problem: What is the correct syntax when using multiple variables in an expression?

E.g.:

=Num(Count({$<[Receipt Time Difference]={">=1"}>} [Trade ID])/Count([Trade ID]),'##.##%')

works, but only after I defined Receipt Time Difference on load. I wanted to use something like

=Num(Count({$<[Receipt To]-[Receipt From]={">=1"}>} [Trade ID])/Count([Trade ID]),'##.##%')

but couldn't get any ()/[]/{}/$ combination to work. What would have been the correct syntax here?

Thanks!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

In a set expression, you can use only [edit: single] field names left from the equal sign [edit: no calculations / expressions], so it would really be appropriate and performant to calculate this field in the script.

[edit:] You can maybe use a set expression with an advanced search, but the performance would be worse than using a precalculated field.

View solution in original post

6 Replies
swuehl
MVP
MVP

In a set expression, you can use only [edit: single] field names left from the equal sign [edit: no calculations / expressions], so it would really be appropriate and performant to calculate this field in the script.

[edit:] You can maybe use a set expression with an advanced search, but the performance would be worse than using a precalculated field.

Gysbert_Wassenaar

You're better off calculating the difference in the script. But perhaps this will work:

=Num(Count({$<[Trade ID]={'=[Receipt To]-[Receipt From]>=1'}>} [Trade ID])/Count([Trade ID]),'##.##%')


talk is cheap, supply exceeds demand
alexandros17
Partner - Champion III
Partner - Champion III

It is not possible to do directly what you have written, you should build a field (in the script) that computes [Receipt To]-[Receipt From] and then use that new field in your set analysis

Hope it heklps

Not applicable
Author

Great, thank you!

Guess I'll have to do it this way then.

swuehl
MVP
MVP

Sorry, I don't understand.

Looks like your expression already uses a single field name Spilled from your data model, just selecting value 1.

edit: and yes, aliasing the field spilled to Spilled will work, if spilled is part of your input table.

Not applicable
Author

edit