2017 Oct 27 10:47 AM - edited 2024 Feb 04 12:48 AM
Hi All,
I want to populate new column based of sales different / day difference.
8/8/2016 - 7/30/2017 = 356 day
sales different in two year.
Day difference between two dates.
new field = sales different in two year / Day difference between two dates *365
Regards,
Kamruz
Request clarification before answering.
Hi,
Thanks for the reply
I used Window Function LEAD and got solved. Closing this thread.
Regards,
Kamruz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kamruz,
In order to solve your problem you need 2 generated column in your table:
1. finding the prior record date
2. Finding the prior record Sales amount
In order to solved this, you can use a SQL script to find the corresponding data:
select
a.*,
b."SDATE" as PDate,
b."sales" as PSales
from (select
"SNO",
"SDATE",
"SYEAR",
"sales" ,
row_number() over (partition by "SNO"
order by "SDATE" asc) as scounter
from "SAPBODS"."test_table") a
left outer join (select
"SNO",
"SDATE",
"SYEAR",
"sales",
(scounter)+1 as pcounter
from ( select
"SNO",
"SDATE",
"SYEAR",
"sales" ,
row_number() over (partition by "SNO"
order by "SDATE" asc) as scounter
from "SAPBODS"."test_table")
--where scounter > 1
) b on a."SNO" = b."SNO"
and a.scounter = b.pcounter;
This would sort the data in the ascending order and provide you the previous Data and Sales amount in the same row, making it easier for calculation.
You can then build a HANA model to perform the division.
thanks,
Kumar Attangudi Perichiappan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
30 | |
9 | |
7 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.