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

Expression for new orders using set analysis

Hey!

I need help to create an expression.

I have three tables, which i select from the database - Orders, Order_type and Clients.Capture2.PNG

1. First you have to insert right dates (I have calendars/sliders named date_range_start and date_range_end) new.PNG

2. Now i want to know how many new orders i have for my order types (Starts in the date range and this client doesn't have any orders for two months ago) If client had an order for example three/four months ago then it's new order.

Result would be: Capture.PNG

And I need to use EXPRESSIONS

So i tried to use set analysis but i don't know how to put it together.

I tried to get orders which start in the range, then subtract these (clients) who had orders in past two months AND NOW I HAVE TO SUBTRACT SOMETHING MORE OR CHANGE THE WHOLE COUNT, I don't know anymore

=Count({<START={"$(='>='&  date_range_start& '<=' & date_range_end)"}>- <END={"$(='>='& MAKEDATE(year(date_range_start),MONTH(date_range_start)-2,day(date_range_start)) & '<' & date_range_start)"}>} OrderID)

I don't even know if I'm close to my solution or not. I have tried this so long now and I still don't have a solution.

I'm happy if somebody could help or guide me.

11 Replies
Anonymous
Not applicable
Author

Your last post was very helpful, now i can see what orders it counts.

And it doesn't make sense, the function counts orders even from last year, it doesn't depend on my date range.

Yes, it shows only those clients orders who has END in the range but counts orders wrongly.

Anonymous
Not applicable
Author

I think I got something that works now. I tried to use somekind a intersection.

=count({1<ClientID= p({1<Start={"$(='>='&  date_range_start& '<=' & date_range_end)"}>} ClientID),

  Start={"$(='>='&  date_range_start& '<=' & date_range_end)"}>}  DISTINCT OrderID)

Thank you so much!