atriumai

Doug YTD/PYTD 3

Sep 9th, 2019
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. q = load "opportunity";
  2. q_A = filter q by date('CloseDate_Year','CloseDate_Month', 'CloseDate_Day') in ["current fiscal_year" .. "current day"];
  3. q_B = filter q by date('CloseDate_Year','CloseDate_Month', 'CloseDate_Day') in ["1 fiscal_year ago" .. "current day - 1 year"];
  4. result = group q_A by 'Account.Name' full, q_B by 'Account.Name';
  5. result = foreach result generate coalesce(q_A.'Account.Name', q_B.'Account.Name') as 'Account.Name', sum(q_A.'Amount') as 'ytd', sum(q_B.'Amount') as 'pytd';
  6. result = order result by ('Account.Name' asc);
  7. result = limit result 2000;
Add Comment
Please, Sign In to add comment