Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All,
I have a table that shows the date for the record and the previous date (i.e. Date From - 01/01/2011 Date To - 10/01/2011) for everythign with 'Type A'. I would like to show on this row the number of records that fall between Date From and Date To. Now, the issue I have is I want to count all the records that are of Type B.
I'm using a simple Set Analysis expression to calculate my amount:
sum({$<tr_type = {'CYC-RCNT'}>} tr_qty_loc)
And to get the previous date I'm using this in the load script..
If(tr_part = Previous(tr_part), date(previous(tr_effdate)), 'N/A') AS tr_DateFrom,
I tried an IF statement (If greater than date and less than, then count (Field1)) but this doesn't work!
I hope you can help me!
Kind Regards,
Dayna
Hello Dayna,
If I understand correctly you want to know how many records are between one date and another. I'd do that in the script, according to my previous one, using something like
If(Product = Previous(Product), RangeSum(Peek('Count'), 1), 1) AS Count,
Then, you will need to use instead the Max(Count) per dimension (Product, in your example), since all records will have a value for "Count" (1, 2, 3, etc)
Hope that helps.
Hello Migual,
Thank you for your response, it is indeed in reference to your last post which I've amended to do the following:
If
(tr_part = Previous(tr_part) AND tr_type = 'CYC-RCNT', date(previous(tr_effdate)), 'N/A') AS tr_DateFrom,
Kind Regards,
Dayna
Hello Dayna,
Something like the following (not sure about your field names and so):
DataWithPreviousDate:LOAD Product, Date AS DateTo, If(tr_part = Previous(tr_part) AND tr_type = 'CYC-RCNT', Date(Previous(tr_effdate)), 'N/A') AS tr_DateFrom, If(tr_part = Previous(tr_part) AND tr_type = 'ISS-WO', RangeSum(Peek('IISWOCount'), 1), 1) AS IISWOCount, AmountRESIDENT OriginalDataORDER BY Product, Date;
Hope that makes sense.
Hello Miguel,
Where it's 'Count' in the expression, do I need to change this for the field I need to count - tr_lot?
I've tried pasting what you have above directly into my sheet but no joy!
Many thanks for your continued help,
Kind Regards,
Dayna
Again, my fault, I missed the fieldname there. Let's take a look at the new field we are creating:
If(tr_part = Previous(tr_part) AND tr_type = 'ISS-WO', RangeSum(Peek('ISSWOCount'), 1), 1) AS ISSWOCount
It will read "if the value in tr_part of the current record equals to the value for tr_part in the previous record, and tr-typr equals to 'ISS-WO', then add 1 to the last value in field ISSWOCount, otherwise set it to 1".
Peek() in this case returns the last value in a field ISSWOCount. RangeSum() just adds 1 to the current value of ISSWOCount for a given record.
It's not counting anything, actually, rather than creating a counter (as such will store from 1 to all possible values in the field). Assume that tr_part has 3 records where tr_type equals to 'ISS-WO'. ISSWOCount will have values 1, 2 and 3. Using Max(ISSWOCount) will return how many records are. Doing this in the script will save time and complexity in the expressions part in the charts.
I've attached a very simple example based on your post so you get the counter in this way for each product.
Hope that helps.
Hello Miguel,
Your very helpful, thank you for all your effort in the above.. I can see exactly what you mean, as it'll give me a count of ISS-WO per product.
For my next question, will the above be smart enough to give me a value for how many ISS-WO's there are between Data From and To for a CYC-RCNT?
Kind Regards,
Dayna
Hi,
It should be enough changing the field for the value you are actually looking for:
If(tr_part = Previous(tr_part) AND tr_type = 'CYC-RCNT', RangeSum(Peek('Count'), 1), 1) AS Count,
Is that correct?
I will certainly give it a go! Thanks again!
Hello Miguel,
The figures still don't work, I've attached what I currently have.. The best example is one of the last records, where the Date From and Date To for the CYC-RCNT's is 01/03 - 06/03. In the other table, I can see there's 6 ISS-WO entries between these dates...
I hope you can help!
Kind Regards,
Dayna