Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 16090

How to calculate the projection

$
0
0

I'm create a Data Engineer model in Snowflake where I need to calculate the projection at weekly level

Formula to calculate the projection : (left over supply in previous week) + (current week supply) - (current week demand)

TABLE

SupplyDemandWeek_Start_Date
150050015-04-2024
050022-04-2024
050029-04-2024
050006-05-2024
50050020-05-2024
050003-06-2024
050010-06-2024
050017-06-2024
1000050024-06-2024
050001-07-2024
050008-07-2024

OUTPUT

SupplyDemandWeek_Start_DateProj
150050015-04-20241000
050022-04-2024500
050029-04-20240
050006-05-2024-500
50050020-05-2024-500
050003-06-2024-1000
050010-06-2024-1500
050017-06-2024-2000
1000050024-06-20247500
050001-07-20247000
050008-07-20246500

Created some solution using LAG window function to calculate projection but not getting the desired output


Viewing all articles
Browse latest Browse all 16090

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>