Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ritvik4BI
Partner - Contributor III
Partner - Contributor III

QlikView script to flow previous month values if current month value is zero

Hi All,

I have two fields-  Month and Sales. I have been trying to write the QlikView script for the following scenario:

If for a month, the Sales value is 0, then the previous month's value should flow into it.  For example if the Sales for the month June is 0, then the previous month i.e. May Sales value should flow into it. 

I have attached the excel file FYR. 

1 Reply
QFabian
Specialist III
Specialist III

Hi @ritvik4BI , please try this :

LOAD
      Month,
      if( Sales = 0, previous(Sales), Sales) as Sales
FROM [..\Downloads\Scenario101.xlsx] (ooxml, embedded labels, table is Sheet1);

 

This is the basic example, with previous function ,

Take care about your data types for ensure correct results, and about order logic too.

greetings!

QFabian