Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have tried the formulars below and they have not worked, wonder if there is something I am missing,
Sum({<DateField={'$(=Max(DateField)-1)'}>} ValueField)
Below(Count(ValueField))
Try it in this way: Sum({<DateField={"$(=date(Max(DateField)-1))"}>} ValueField)
Thanks, but that didn't work. Is there Anything I need to do before using this as an expression?
Try this
Sum({<DateField = {"$(=Max(DateField)-1)"}>} ValueField)
subtracting the date -1 will return a number, you just need to reformat it to match the formatting of the date in Datefield
Sum({<DateField={"$(=Date(Max(DateField)-1,'YYYY-MM-DD'))"}>} ValueField)
replace YYYY-MM-DD with the format in DateField
Make sure that DateField is a real date and not a timestamp and not a string. That field-values look like a date doesn't mean that they are one. Further this field needs to have the same formatting as the default-format for dates or you would need to specify the wanted formatting within date().
Thanks so far. To give you an example.
Here is my script presently
OrderData:
Load*
Inline [
InvoiceID|CustomerID|ProductID|Units|Date
1|Ast|1|8|01/01/2021
1|Ast|2|6|01/02/2022
2|Bet|3|10|02/01/2021
3|Diva|3|5|12/05/2021
4|Diva|4|10|02/06/2022
] (delimiter is '|');
OrderData_Temp:
Load *, Previous(Units) as Pre_Units
Resident OrderData;
Drop table OrderData;
And the output is
First Bet row and Diva should be blank the same way Ast first Row is blank. The code doesnt seem to understand the previous time by the category (customerID)