changed

changed, function

def process changed(value: any): boolean

Returns true when value differs from the previous value in the ordered sequence; the first element is always true.

Examples

table T = with
  [| as Id, as Category |]
  [| 1,    "A"          |]
  [| 2,    "A"          |]
  [| 3,    "B"          |]
  [| 4,    "B"          |]
  [| 5,    "A"          |]

T.HasChanged = changed(T.Category) scan T.Id

show table "Category changes" with
  T.Id
  T.Category
  T.HasChanged

Output:

Id Category HasChanged
1 A true
2 A false
3 B true
4 B false
5 A true

Remarks

This process requires scan or sort to specify the comparison order. It works with any type that supports equality.

See also

User Contributed Notes
0 notes + add a note