Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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;
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;
Thank you @brunobertels
why my above expression not worked, why yours worked can you kindly explain it.
Thanks again,
Eshwar
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 :
Peek behaviour :
Regards
Thank you for information @brunobertels