Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
DawidDaw
Contributor III
Contributor III

Set analysis with long list of conditions

Hello,

I have a table containing a list of dimensions called Segments. There are 65 segments called S0001, S0002, S0003 ... S0065.

I need to filter my sum by some of these segments. There are three main measures:

  • Internal Segments -> S0001 - S0022
  • External Segments -> S0023 - S0050
  • Other Segments -> S0051 - S0065

I am currently using simple and shorter measures with following expression: 

=sum({<segment_id={'S0001', 'S0002', 'S0003','S0004'}>}line_amount)

This will become troublesome and very long when I add all the segments. Especially because at a later stage, other dimensions will be added (ex: Group, G0001 - G0100 etc).

How could I facilitate or automate this expression? I was exploring using a Right(segment_id,2) < 23 for instance, but it does not seem to work. I can't handle the syntax.

I am at this point not willing to create flags in the script due to constraints given by the client.

 

Thanks!

Labels (1)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

=sum({<segment_id={"=Num(Right(segment_id,2)) > 23  AND Num(Right(segment_id,2)) < 50"}>}line_amount)

View solution in original post

4 Replies
tresesco
MVP
MVP

May be like:

=sum({<segment_id={"=Num(Right(segment_id,2)) < 23"}>}line_amount)

DawidDaw
Contributor III
Contributor III
Author

Nice, this seems to work properly!

How would you apply the condition for the segment id to be between 23 & 50?

tresesco
MVP
MVP

=sum({<segment_id={"=Num(Right(segment_id,2)) > 23  AND Num(Right(segment_id,2)) < 50"}>}line_amount)

DawidDaw
Contributor III
Contributor III
Author

Thank you