Skip to main content
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

There is, but this is probably the best way to handle your situation... others are going to be very slow on the front end... if you would like... I can guide you there as well... but look here before you think of going there

The As-Of Table

paolocamerini
Partner - Contributor III
Partner - Contributor III
Author

I tried to create the AsOfTable in my datamodel, however I'm getting the sum of the amounts for every record and not only those whose sum is larger than "x".

I'm in a daze

sunny_talwar

Did you look at the expression that I have used?

Capture.PNG

paolocamerini
Partner - Contributor III
Partner - Contributor III
Author

Sure. I noticed that in your example, AsOfData takes the place of Data. In my application this doesn't happen.

sunny_talwar

But did you not create a AsOfDate in your AsOfTable?

paolocamerini
Partner - Contributor III
Partner - Contributor III
Author

This is what I get after creating the AsOfTable

  

DataAsOfData
01/09/201726/08/2017
01/09/201727/08/2017
01/09/201728/08/2017
01/09/201729/08/2017
01/09/201730/08/2017
01/09/201731/08/2017
01/09/201701/09/2017
02/09/201727/08/2017
02/09/201728/08/2017
02/09/201729/08/2017
02/09/201730/08/2017
02/09/201731/08/2017
02/09/201701/09/2017
02/09/201702/09/2017
03/09/201728/08/2017
03/09/201729/08/2017

[...]

sunny_talwar

Right, so why can't you use this as your expression?

=Sum({<AsOfData = {"=Sum(Amount) > 25"}>}Amount)

paolocamerini
Partner - Contributor III
Partner - Contributor III
Author

In my application, using that expression, results in showing every single record (x7 times) AsOf.jpg

sunny_talwar

What happens if you don't have AsOfData as your dimension?

paolocamerini
Partner - Contributor III
Partner - Contributor III
Author

It sums the amounts correctly but shows values lower than 15000 too