I'm trying to figure out something in SQL but thought I might be able to use a VBA macro (in excel or access) to solve this problem so I am posting this question in here as well.
I'm thinking there might be a way to loop through in a VBA macro and write in formulas in the calculated columns to get what I want. I start with the first 3 columns in my example and the next 4 would all be calculations.
I've put an example below but I'll try and explain it in words too. I start with a Billed amount. 100% of that goes into the member bucket until the Member Cumulative cost hits Limit 1. In this case limit 1 is $750. Between Limit 1 and Limit 2 ($1500), 20% of billed goes into Member and 80% of billed goes into Plan. Once the Member Cumulative cost hits Limit 2, 100% of Billed goes into Plan.
Here's an example
Month -- ID --- Billed -- Plan_Month -- Plan_Yr_Ttl -- Mbr_Month -- Mbr_Yr_Ttl
Jan ---- 100 --- 500 --------- 0 ------------ 0 ----------- 500 --------- 500
Feb ---- 100 --- 300 -------- 240 ----------- 240 --------- 60 --------- 560
Mar ---- 100 --- 400 -------- 320 ----------- 560 --------- 80 --------- 640
Apr ---- 100 --- 800 -------- 690 ----------- 1250 --------- 110 --------- 750 *Limit 1 is $750 - 20% would have hit 800 so 50 subtracted and added to Plan
May ---- 100 --- 1000 ------- 800 ----------- 2050 --------- 200 --------- 950
Jun ---- 100 --- 600 -------- 480 ----------- 2530 --------- 120 --------- 1070
Jul ---- 100 ---- 700 -------- 560 ----------- 3090 --------- 140 --------- 1210
Aug ---- 100 --- 800 -------- 640 ----------- 3730 --------- 160 --------- 1370
Sep ---- 100 --- 800 -------- 670 ----------- 4400 --------- 160 --------- 1500 *Limit 2 is $1500, 20% would have hit $1550 so 30 subtracted and added to Plan
Oct ---- 100 --- 200 -------- 200 ----------- 4600 --------- 0 --------- 1500
Nov ---- 100 ---- 0 ---------- 0 ------------ 4600 --------- 0 --------- 1500
Dec ---- 100 --- 100 -------- 100 ----------- 4700 --------- 0 --------- 1500
I'm thinking there might be a way to loop through in a VBA macro and write in formulas in the calculated columns to get what I want. I start with the first 3 columns in my example and the next 4 would all be calculations.
I've put an example below but I'll try and explain it in words too. I start with a Billed amount. 100% of that goes into the member bucket until the Member Cumulative cost hits Limit 1. In this case limit 1 is $750. Between Limit 1 and Limit 2 ($1500), 20% of billed goes into Member and 80% of billed goes into Plan. Once the Member Cumulative cost hits Limit 2, 100% of Billed goes into Plan.
Here's an example
Month -- ID --- Billed -- Plan_Month -- Plan_Yr_Ttl -- Mbr_Month -- Mbr_Yr_Ttl
Jan ---- 100 --- 500 --------- 0 ------------ 0 ----------- 500 --------- 500
Feb ---- 100 --- 300 -------- 240 ----------- 240 --------- 60 --------- 560
Mar ---- 100 --- 400 -------- 320 ----------- 560 --------- 80 --------- 640
Apr ---- 100 --- 800 -------- 690 ----------- 1250 --------- 110 --------- 750 *Limit 1 is $750 - 20% would have hit 800 so 50 subtracted and added to Plan
May ---- 100 --- 1000 ------- 800 ----------- 2050 --------- 200 --------- 950
Jun ---- 100 --- 600 -------- 480 ----------- 2530 --------- 120 --------- 1070
Jul ---- 100 ---- 700 -------- 560 ----------- 3090 --------- 140 --------- 1210
Aug ---- 100 --- 800 -------- 640 ----------- 3730 --------- 160 --------- 1370
Sep ---- 100 --- 800 -------- 670 ----------- 4400 --------- 160 --------- 1500 *Limit 2 is $1500, 20% would have hit $1550 so 30 subtracted and added to Plan
Oct ---- 100 --- 200 -------- 200 ----------- 4600 --------- 0 --------- 1500
Nov ---- 100 ---- 0 ---------- 0 ------------ 4600 --------- 0 --------- 1500
Dec ---- 100 --- 100 -------- 100 ----------- 4700 --------- 0 --------- 1500