7 Replies Latest reply: Jul 20, 2016 4:58 AM by Joanna Seldon

# peek or pervious when simular number

hi

I am trying to see if next number is lower than the next...but I am having issues when it sees the first number or next

I have tried both expressions

if((Sales)< peek(sales),'1','0') as flag

if((Sales)< previous(sales),'1','0') as flag

basically

Month 1 , sales = 10     ...flag = 1

Month 2,  sales = 9.8   ... flag = 1

Month 3,  sales = 9.9  ....flag =  0

Month 4  Sales = 9.9   ... flag = 0

Month 5  Sales = 15   .... flag = 0

how can I make Month 1 flag be 0?

• ###### Re: peek or pervious when simular number

Is the field Sales or sales - QV field names are case sensitive.

The correct syntax would be:

If(Sales < Alt(previous(Sales), 0), 1, 0) as flag,

• ###### Re: peek or pervious when simular number

hi

I have tried both and both give me same answer I have been getting

• ###### Re: peek or pervious when simular number

Hi

Note : I am assuming   'Sales' as field name ...

• ###### Re: peek or pervious when simular number

Hi

after some testing ..it only works, if field is cast as an int ...not numeric

thanks guys for your help x

• ###### Re: peek or pervious when simular number

HI,

You need to make sure you data is orders by the month,

Then you Can do something like

IF(RowNo() = 1,

0,

IF(Sales < previous(Sales),

1,

0

)

) as flag,

If you have multiple years you can add a check for year in a similar fashion

Mark

• ###### Re: peek or pervious when simular number

are your months strings or numbers ?

if they are string, then try adding a number and apply the sort on a descending way, peek or previous should work as long as you use the same field name, like Jonathan already suggested

• ###### Re: peek or pervious when simular number

Hi guys

still a problem,

I have tried order by month too

I have even tried

Num(replace(Sales, ' ', '')) as Sales... to make sure it sees a number field

I am guessing its rounding the figure? because its decimal places?