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

Set analysis with count function

Hi,

I have a sales table and want to count the no. of customer that only have one transaction in the year.

Tx Date     Invoice No.     Customer ID     Sales Amount

Jan 2013     A0000          CS0001         

Jan 2013     A0001          CS0002

Jan 2013     A0002          CS0001

Feb 2013     A0003          CS0001

Jan 2014     A0004          CS0003

Jan 2014     A0005          CS0003

Feb 2014     A0006         CS0002

My expected result will be

Year     No. of one time purchase customer

2013     1

2014     1

Can I use a count function in a set analysis to filter those Customer ID that has multiple sales?

1 Solution

Accepted Solutions
simondachstr
Luminary Alumni
Luminary Alumni

An even more slicker expression without using an if statement:

=sum(-aggr(Count([Customer ID])=1,[Customer ID],Year))

View solution in original post

7 Replies
tresesco
MVP
MVP

If you are thinking of using a chart, set analysis might not be the solution. Try:

Straight table:

Dim: Year

Exp1: FirstsortedValue(CustomerID, Aggr(Count(CustomerID),Year,CustomerID))

Exp2:Count(If(Aggr(Count(CustomerID), Year, CustomerID)=1, CustomerID))

Edit: Corrected

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

=Count(Aggr(If(Count(CustomerID) =1, 1), Year, CustomerID))


Regards,

Jagan.

mdmukramali
Specialist III
Specialist III

Dear,

Kindly find the attached file.

Thanks

Mukram

simondachstr
Luminary Alumni
Luminary Alumni

An even more slicker expression without using an if statement:

=sum(-aggr(Count([Customer ID])=1,[Customer ID],Year))

Not applicable
Author

Thanks all for the tips

simondachstr
Luminary Alumni
Luminary Alumni

Can you mark the one that helped your case as the correct one please.

This could help other users with a similar issue.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Close this thread if you got the answer by giving Correct and Helpful answers to the useful posts.

Regards,

Jagan.