Skip to main content

Can someone give me an example of when we should use previous VS previous on? Such as, previous(month) VS

PREVIOUS(Month ON -RANK(Month.'Start Date')

Hi ​@Nusayba ,

You can use the ON parameter if you want to use an alternative order of your dimension. By default the previous (and also other functions like lastnonblank or firstnonblank) follow the natural order of your dimension. 
If you want to use a different order, instead of re-ordering the list, you can use the ON parameter.

Hope this helps,


PREVIOUS(Dimension, offset)

Dimension of the current source metric on which we would like to apply an offset

offset (optional) is an integer N that allows returning the Nth value before. By default, the value is 1.

PREVIOUS(Dimension ON -RANK(dimension.Rank_Property), offset)

dimension.Rank_Property is a NUMBER, INTEGER, DATE Property that can be naturally ordered with the RANK() function. This expression will reverse the rank of the Dimension items, and results will go backward (in the opposite direction as if you were doing PREVIOUS(Dimension) )


Reply