Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Eshwar1
Contributor III
Contributor III

display the missing Sales values based on Projections

Hi All

I have below sample table, Based on projection values i want to display the calculated missing Sales values

Tab:
Load * Inline [
Year, Product , Sales, Projections
2024, Latop,   1000,
2025, Latop,                 10%
2026, Latop,                 15%
2027, Latop,                  12
2024, Mobile,  1500,
2025, Mobile,              15%
2026, Mobile,              10%
2027, Mobile,              14%
];

 

NoConcatenate
CalculatedSalesData:
LOAD
Year,
Product,
If(Len(Trim(Sales)) = 0, Previous(Sales) * (1 + Projections/100), Sales)  AS Sales,
Projections
Resident Tab
ORDER BY Product, Year;

Drop table Tab;

to achieve Implemented above code in "CalculatedSalesData" Table, but not getting desired values

what's the issue here not able to find out that.

Can you suggest it.

Thanks

Eshwar

 

 

Labels (1)
1 Solution

Accepted Solutions
brunobertels
Master
Master

Hi 

I did it like that 

 

Tab:
Load * Inline [
Year, Product , Sales, Projections
2024, Latop, 1000,
2025, Latop, , 10%
2026, Latop, , 15%
2027, Latop, , 12%
2024, Mobile, 1500,
2025, Mobile, , 15%
2026, Mobile, , 10%
2027, Mobile, , 14%
];

 

NoConcatenate
CalculatedSalesData:
LOAD
Year,
Product,
//If(Len(Trim(Sales)) = 0, Previous(Sales) * (1 + Projections/100), Sales) AS Sales,
If(Len(Trim(Sales)) = 0, peek(Sales)+peek(Sales) * Projections,Sales) AS Sales,
Projections
Resident Tab
ORDER BY Product, Year;

Drop table Tab;

brunobertels_0-1724937897276.png

 

 

View solution in original post

4 Replies
brunobertels
Master
Master

Hi 

I did it like that 

 

Tab:
Load * Inline [
Year, Product , Sales, Projections
2024, Latop, 1000,
2025, Latop, , 10%
2026, Latop, , 15%
2027, Latop, , 12%
2024, Mobile, 1500,
2025, Mobile, , 15%
2026, Mobile, , 10%
2027, Mobile, , 14%
];

 

NoConcatenate
CalculatedSalesData:
LOAD
Year,
Product,
//If(Len(Trim(Sales)) = 0, Previous(Sales) * (1 + Projections/100), Sales) AS Sales,
If(Len(Trim(Sales)) = 0, peek(Sales)+peek(Sales) * Projections,Sales) AS Sales,
Projections
Resident Tab
ORDER BY Product, Year;

Drop table Tab;

brunobertels_0-1724937897276.png

 

 

Eshwar1
Contributor III
Contributor III
Author

Thank you @brunobertels 

why my above expression not worked, why yours worked can you kindly explain it.

 

Thanks again,

Eshwar

brunobertels
Master
Master

Hi 

see this link for further informations about Peek and Previous functions : 

"The two functions Peek() and Previous() are similar, but still fundamentally different. Previous() operates on the input to the Load statement, whereas Peek() operates on the output of the Load statement.

This means that it makes a big difference for Peek() if a field is included in the Load statement or not. But it doesn't affect Previous() at all."

https://community.qlik.com/t5/Design/Peek-vs-Previous-When-to-Use-Each/ba-p/1475913 

 

and here an example with a table to see the behaviour of peek and previous function :

https://www.bitmetric.nl/blog/qlik-peek-or-previous/ 

 

previous behaviour : 

brunobertels_0-1725002625064.png

Peek behaviour :

brunobertels_1-1725002666085.png

 

Regards 

Eshwar1
Contributor III
Contributor III
Author

Thank you for information @brunobertels