Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
My_Rebecca
Creator
Creator

How to load the lastest non-blank figure?

How to load the lastest non-blank figure by expression?

eg:

if today() is 3/27/2023, the result is 3650;

if today() is 4/3/2023, the result is 1660;

if today() is 4/6/2023, the result is 4685;

if today() is 4/10/2023, the result is 6685.

My_Rebecca_0-1680491187451.png

 

Labels (1)
1 Solution

Accepted Solutions
sandeep-singh
Creator II
Creator II

Hi @My_Rebecca, The field was created in the preceding load. I have created a dummy script to give you an idea. 

Script:

sandeepsingh_1-1680614128665.png

Data load progress:

sandeepsingh_0-1680614049676.png

Output: 

sandeepsingh_2-1680614240946.png

 

 

View solution in original post

13 Replies
sandeep-singh
Creator II
Creator II

Try this

Dummy:
load * inline [
Week,Date,Total DHL DN line
2023-WK12,3/21/2023,8707
2023-WK12,3/22/2023,
2023-WK12,3/23/2023,5650
2023-WK12,3/24/2023,
];


Load
Week,
Date,
if(Len(Trim([Total DHL DN line]))=0, peek('Total DHL DN line_1'),[Total DHL DN line]) as [Total DHL DN line_1]
Resident Dummy;

drop table Dummy;

My_Rebecca
Creator
Creator
Author

@sandeep-singh 

dear, there are many lines in this sheet and I needn't the script, but expression while editing the sheet in app, so could you please support to have another look at this question? thanks.

sandeep-singh
Creator II
Creator II

Try this

You can use the below script in the measure

=if(len(trim([Total DHL DN line]))=0
,above([Total DHL DN line])
,[Total DHL DN line])

My_Rebecca
Creator
Creator
Author

@sandeep-singh 

dear,

what about "if today() is 4/10/2023, the result is 6685"? The result is not above line, but above 2 lines. It should be nearest non-blank, not above.

My_Rebecca
Creator
Creator
Author

Is there anyone who can support me on this expression? thanks.

sandeep-singh
Creator II
Creator II

There is no such alternative of "peek" function in the front end. The best possible that you can do is add a piece of script mentioned in the previous conversation or you can add it with preceding load like below, but do verify the table count as I am not aware of your data model

load *,
if(Len(Trim([Total DHL DN line]))=0, peek('Total DHL DN line_1'),[Total DHL DN line]) as [Total DHL DN line_1]
;

My_Rebecca
Creator
Creator
Author

@sandeep-singh 

dear, please look at my data model. It contains hundreds of rows here.

could you please support to edit the script here? Many thanks.

My_Rebecca_0-1680532673789.png

 

sandeep-singh
Creator II
Creator II

You just have to add this piece of script as a preceding load where you are loading these fields from data source. Adjust the field name accordingly.

load *,
if(Len(Trim([Total DHL DN line]))=0, peek('Total DHL DN line_1'),[Total DHL DN line]) as [Total DHL DN line_1]
;

My_Rebecca
Creator
Creator
Author

Dear @sandeep-singh , 'Total DHL DN line_1' does not exist, so I think the preceding loading would be infeasible. Is there any other way to solve this issue? thanks.