Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Gabri
Contributor III
Contributor III

Repetitive customer by year

Hello community,

I have a question with a KPI function and I would like to know if you can help me.

I want to know how many clients, specified one year, have bought us in the previous year, for example:

CLINAMEYEARINVOICE NUMAMOUNT
CA2019540
CA2019440
CA2019322
CA2019210
CA2019115
CA2018110
CBb2018220
CBb2018120
CCcc2019228
CCcc2019120
CCcc2018110
CCcc2017110
CDddd2019150

 

YEAR    2019    
        
TOTAL CLIENTS (2019)    3  'solved'
TOTAL INVOICES (2019)   8    'solved'
TOTAL AMOUNT   (2019)  225    'solved'
        
Repetitive customer (2019)    2    'I don't know how to get this value'

 

Thanks in advance,

 

Labels (1)
2 Solutions

Accepted Solutions
uacg0009
Partner - Specialist
Partner - Specialist

Hi Gabri,

The first idea in my mind is in below, I think that's what you want, but I think it must have better solution:

Repetitive customer by year.PNG

=Count(DISTINCT {$<YEAR = {"$(=Only(YEAR) - 1)"}>} if(aggr(sum(AMOUNT) > 0,CLINAME),CLINAME))

Aiolos Zhao

View solution in original post

uacg0009
Partner - Specialist
Partner - Specialist

Hi Gabri,

Please try below expression, it works in my desktop:

=Sum(if(aggr(NODISTINCT sum({<YEAR = {"$(=Only(YEAR) - 1)"}>}AMOUNT) > 0,CLINAME),AMOUNT))

Aiolos Zhao

View solution in original post

12 Replies
uacg0009
Partner - Specialist
Partner - Specialist

Hi Gabri,

The first idea in my mind is in below, I think that's what you want, but I think it must have better solution:

Repetitive customer by year.PNG

=Count(DISTINCT {$<YEAR = {"$(=Only(YEAR) - 1)"}>} if(aggr(sum(AMOUNT) > 0,CLINAME),CLINAME))

Aiolos Zhao

PrashantSangle

try below set analysis.

Count({<CLINAME={"=(Count(CLINAME)>1)"}>}distinct CLINAME)

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Gabri
Contributor III
Contributor III
Author

Thanks Uacg0009, your answer was very good!

Today I want to complicate the function to get the TOTAL Amount of this (2) CLINAME, in this case:

 

CLINAMEYEARINVOICE NUMAMOUNT
CA2019540
CA2019440
CA2019322
CA2019210
CA2019115
CA2018110
CBb2018220
CBb2018120
CCcc2019228
CCcc2019120
CCcc2018110
CCcc2017110
CDddd2019150

 

YEAR    2019    
        
TOTAL CLIENTS (2019)    3  'solved'
TOTAL INVOICES (2019)   8    'solved'

REPETITIVE CUSTOMER (2019)    2    'solved'
TOTAL AMOUNT   (2019)  225    'solved'
TOTAL AMOUNT (2019) Repetitive customer    175  'I don't know how to get this value'

 

Thanks in advance,

PrashantSangle

Try below

Sum({<CLINAME={"=(Count(CLINAME)>1)"}>}AMOUNT)

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Gabri
Contributor III
Contributor III
Author

Hi PrashantSangle, thanks for your answer, but is not correct, your expression return the sum of amounts of clients that has more than 1 invoice in 2019.

I need ( the sum of amounts of repetitive customers)

Repetitive customers (CA, Cccc)

TOTAL AMOUNT (2019) Repetitive customer 175

Thanks

PrashantSangle

Hi,

I have tried the same expression in my qvf and when I select 2019, It is giving me 175.

Regards,
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Gabri
Contributor III
Contributor III
Author

I'm sorry, can you try with this table?

CLINAMEYEARINVOICE NUMAMOUNT
CA2019540
CA2019440
CA2019322
CA2019210
CA2019115
CA2018110
CBb2018220
CBb2018120
CCcc2019228
CCcc2019120
CCcc2018110
CCcc2017110
CDddd2019350
CDddd2019250
CDddd2019150

 

Thanks!

PrashantSangle

what is your expected output? I am getting  325.


Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Gabri
Contributor III
Contributor III
Author

The correct answer is the same, 175. Customer "CDddd" has no invoices in 2018, so you need to ignore

 

Captura.JPG