Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
paolocamerini
Partner - Contributor III
Partner - Contributor III

Help with count (with conditions)

Hello everyone,

I have a dataset (an inch more complex than this but hopefully this will serve) like this:

     

DataTicketIDPersonIDAmount
01/09/20171BGXXXXX1A4
05/09/20172BGXXXXX1A7
05/09/20173BGXXXXX1A2
06/09/20174BGXXXXX1A1
06/09/20175BGXXXXX1A10
07/09/20176BGXXXXX1A11
08/09/20177BGXXXXX1A12
11/09/20178BGXXXXX1A1
15/09/20179BGXXXXX1A1

I need to count for each Data the number of the distinct TicketID that I can find in the very next 7 days but only if the sum of the amount exceeds 25.

I'm expecting this output:

     

DataIDCountSumAmount
01/09/2017BGXXXXX1A635
05/09/2017BGXXXXX1A1144
06/09/2017BGXXXXX1A535
07/09/2017BGXXXXX1A324
08/09/2017BGXXXXX1A314

[...]

Last 2 rows should not appear for their amount is less than 25.

Can't really find a way to achieve my result.

Could anyone of you please help me out?

Thank you!

23 Replies
sunny_talwar

Okay so you have more than one dimension you are checking this on, right? Try this

Sum(Aggr(If(Sum(Importo) > 15000, Sum(Importo), Dim1, Dim2))

paolocamerini
Partner - Contributor III
Partner - Contributor III
Author

Bingo! Looks a lot better. Now it's time to validate the result! Thank you fellow Qlik genius!

paolocamerini
Partner - Contributor III
Partner - Contributor III
Author

Only disadvantage is that the size of the application has increased a lot. I have a couple of questions:

  1. How can this method not create duplicates throughout the records? It looks like the rows (in this case) are repeated 7 times
  2. I have no new synthetic keys, how so?
sunny_talwar

I think size of the dashboard should be not big of a concern considering this will give you much better performance on the front end.

1) They are repeated on the front end, but the back end data stays intact because the fact table have stayed as is, it is the link table (AsOfTable) which have this multiple logic.... one day (asofdate) is conneted to 7 days.

2) No synthetic keys because you are joining on just Data field.....