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

I need to convert this espression in a set analysis expression

Here you are the normal expression:

COUNT(IF(week_ship=week_ship_2, orders))

I tried with this one ... but it doesn't work:

COUNT({1<week_ship={$(=ONLY(week_ship_2))}>} orders)

Anybody ?

Thanks in advance

1 Solution

Accepted Solutions
swuehl
MVP
MVP

This should work in your setting with single week# per order_num in both tables:

=COUNT({1<ord_num = {"=only({1}week1)=only({1}week2)"}>} ord_num)

Not sure if the set expression is much better performing than your original expression ( count(if(..)) ) in this case, do you see an improvement?

View solution in original post

26 Replies
swuehl
MVP
MVP

I assume you want a record based comparison, try

=COUNT({1<week_ship = {"=week_ship=week_ship_2"}>} orders)

Not applicable
Author

thanks but it doesn't work ... I mean if I select week_ship_2 I get a result ... but it's completely different from the result that I want from the first formula.

Not applicable
Author

BTW : week_ship adn week_ship_2 are two fields

Not applicable
Author

Hi tode,

You can try dis,

COUNT({$<week_ship = {'week_ship=week_ship_2'}>} orders)

swuehl
MVP
MVP

Ok, so week_ship and week_ship_2 are not two columns in the same table?

How are they related? What do you want to achieve in a "big picture"?

Not applicable
Author

No they are not two columns of the same table ... they come from two different tables but the two tables are linked through orders (anyway the number of the order)

swuehl
MVP
MVP

And you can have multiple week_ship and week_ship_2 per order?

If yes, how to handle these cases?

Could you give some sample lines of data together with your expected outcome?

Not applicable
Author

api.JPG

These are the two fields.

Anyway ... are there others way to convert COUNT(IF(week_ship=week_ship_2, orders))

in a set analysis ?

swuehl
MVP
MVP

I was more thinking of an example demonstrating your table / field relations like

LOAD * INLINE [

Order, week_ship

1, 1

1, 2

2, 3

3, 4

];

LOAD * INLINE [

Order, week_ship_2

1, 2

2, 3

3, 3

];

And then an example of how you use your expression (in which context, chart object - any information that might help).