Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
379SSS
Contributor III
Contributor III

Need pervious values without nulls

Hi All,

Scenario is like I want all the "sales score" values in customer table and if the "sales score" is null it should pick pervious date "sales score" value without null. Here it should be order by CustomerID and Date.

E.g.

Image2.JPG

Can anyone help me out here to achieve this.

Thanks in advance!!!

Labels (5)
1 Solution

Accepted Solutions
379SSS
Contributor III
Contributor III
Author

below is the solution.

noconcatenate
new_table:
load
CustomerID,
date,
sales_score as orginal_sales_score,
IF( ISNULL(sales_score) or sales_score = 0, PEEK(sales_score), sales_score) AS sales_score

resident table
order by CustomerID, date asc;
drop table table;

View solution in original post

4 Replies
Gabbar
Specialist
Specialist

A:
Load  *,
If (CustomerID = Previous(CustomerID),Previous(SalesScore),null()) as Previous_Score
resident Source order by CustomerID asc, Date asc;

noconcatenate
B:
Load CustomerId,Date,Coalesce(Sales_score,Previous_score) as sales_score resident A;
Drop table A;

379SSS
Contributor III
Contributor III
Author

HI @Gabbar ,

can you recheck the image I have reposted that

Aditya_Chitale
Specialist
Specialist

@379SSS 

Outer join both Customer & sales_score tables and create a new resident table using the outer joined table.

Once done with that, incorporate highlighted changes from below image in your resident table and drop joined table:

Aditya_Chitale_0-1695990326040.png

Output:

Aditya_Chitale_1-1695990649219.png

 

Regards,

Aditya

 

379SSS
Contributor III
Contributor III
Author

below is the solution.

noconcatenate
new_table:
load
CustomerID,
date,
sales_score as orginal_sales_score,
IF( ISNULL(sales_score) or sales_score = 0, PEEK(sales_score), sales_score) AS sales_score

resident table
order by CustomerID, date asc;
drop table table;