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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using min function in target field in set analysis

I have the following table :

CUST_USER_IDPURCHASE_EVENT_DT
104/5/2014
1
05/5/2014
1
07/5/2014
3

04/5/2014

2

10/5/2014

2

10/5/2014

I want to calculate the number of buyers who do their first purchase the date that qlikVIew users select through a calendar object.

For example,

In 04/5/2014, the total number of new buyers are 2 ( cust_user_id: 1 , 3 )

In 05/5/2014, the total number of new buyers is 0

In 10/5/2014, the total number of new buyers is 1 ( cust_user_id: 2 )

I try to do it using the following set analysis :

Count({<min(PURCHASE_EVENT_DT)={$(vSelectedDate)}>} distinct CUST_USER_ID)

But there is an error in set analysis. Can you help me please?

1 Solution

Accepted Solutions
rogerioqv
Creator II
Creator II

Dimitra:

If you can not open the file, use this expression:

='New Customers: ' &COUNT(DISTINCT IF( vDateRef = aggr(min(PURCHASE_EVENT_DT),CUST_USER_ID), CUST_USER_ID))

View solution in original post

6 Replies
rogerioqv
Creator II
Creator II

Try:

Count({<PURCHASE_EVENT_DT={"=$(vSelectedDate)"}>} distinct CUST_USER_ID)


Do not forget that the dates have to be in the same formats.



alexandros17
Partner - Champion III
Partner - Champion III

You cannot use min (or any other function) in the left part of the expression, I think that if the use selects a date the expression can be:

Count(distinct CUST_USER_ID)


or (to be sure of the selected date):


Count({<PURCHASE_EVENT_DT={$(=GetFieldSelections(myFieldDate))}>} distinct CUST_USER_ID)


where myFieldDate is the field in the multibox selected by the user


Let me know

Not applicable
Author

The following set analysis calculates the number of buyers per selected date and not the number of new buyers per selected date.


Count({<PURCHASE_EVENT_DT={$(=GetFieldSelections(myFieldDate))}>} distinct CUST_USER_ID)



If a buyer had had a purchase before the selected date, he should not be appeared  as new buyer in the selected date but he should be appeared as new buyer the date that he had done his first purchase.

So, i want to select a date and see the number of users who did their first purchase this date.



rogerioqv
Creator II
Creator II

Dimitra,

See the attachment.

rogerioqv
Creator II
Creator II

Dimitra:

If you can not open the file, use this expression:

='New Customers: ' &COUNT(DISTINCT IF( vDateRef = aggr(min(PURCHASE_EVENT_DT),CUST_USER_ID), CUST_USER_ID))

Not applicable
Author

Thank you very much. This is exactly what i want to do.

Have a nice day.