Hello - I am trying to create a waterfall chart that shows 2 values (e.g. current week forecast and prior week forecast) and have it calculate the variance between the two. However it seems that the waterfall chart can only add values and compute the total (last bar) as opposed to calculate the difference between the bars. Is there a way to accomplish this?
Please see this example code and the video on how I put this all together with a minimum of writing code on my own:
q = load "opportunity1";
start = filter q by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in ["1 week ago".."1 week ago"];
start = group start by all;
start = foreach start generate sum('Amount') as 'A', "1-start" as 'Bucket';
q_A = filter q by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in ["1 week ago".."1 week ago"];
q_B = filter q by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in ["current week".."current week"];
diff = cogroup q_A by all full, q_B by all;
diff = foreach diff generate sum(q_A.'Amount') as 'A', sum(q_B.'Amount') as 'B';
diff = foreach diff generate B-A as 'A', "2-difference" as 'Bucket';
result = union start, diff;
result = group result by 'Bucket';
result = foreach result generate 'Bucket', sum('A') as 'value';