
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Calculate Previous date value
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))
- Subscribe by Topic:
-
Developers
-
expression
-
Script
-
Set Analysis
-
Variables
-
Visualization


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try it in this way: Sum({<DateField={"$(=date(Max(DateField)-1))"}>} ValueField)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, but that didn't work. Is there Anything I need to do before using this as an expression?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this
Sum({<DateField = {"$(=Max(DateField)-1)"}>} ValueField)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
If a post helps to resolve your issue, please accept it as a Solution.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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().

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
