Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

If value is zero, show previous non-zero value

Hello,

I am new to Qlik Sense and I would like to know how to mentioned in the UI layer (not the script) to assign a previous value if a given measure is equal to zero.

In this example, We have date as a dimension and price as a measure, if list price is equal to zero for a given finalized date, we want the price to be the price of the last non-zero price.

This is what is shows right now

Capture.PNG

This is what I want it to show.

Capture1.PNG

is there any way we can do this for all cases like this?

16 Replies
sunny_talwar

It is, but not the ideal way to do it....

Digvijay_Singh

Do we need another column? What if we do all the checking in the Price column itself. Not sure though?

Load * inline [

Date, Price

1/02/2014,2000

4/21/2014,23431

6/27/2015,34125

11/02/2017,0

12/31/2017,0

1/10/2017,0

1/12/2017,0

1/13/2017,0

1/16/2018,12343 ];

Capture.PNG

sunny_talwar

We don't ... that is sort of where this all started from... but Omar already had two expressions.... so that is why Column(3).

The basic idea is to self reference the expression for the value it shows on the previous row.

Digvijay_Singh

Yeah, right. hope nathan.parmeswar got options to move forward.

OmarBenSalem

How to handle this in the script sunny?

sunny_talwar

Much more easier to do this in the script

If(Price = 0, Peek('New_Price'), Price) as New_Price

Anonymous
Not applicable
Author

Thank you Sunny, Omar, and Digvijay. Very helpful.