title: Calculated YTD using date column and group by multiple column?
body: <p>I have a table with columns:
  <a href="https://i.stack.imgur.com/byoXZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/byoXZ.png" alt="enter image description here"></a></p>
  
  <p>I'm trying to calculate accounts payable in days <code>= (Accounts Payable/YTD_Vendor_Expenses)*Number of days in Period</code>.</p>
  
  <p>I'm trying the below query but doesn't seem to work(I'm running the query in ZOHO analytics):</p>
  
  <pre><code>SELECT groupkey,
  `Total Accounts Payable`,
  Report_Month,
  `Total Income`,
  month(`Report_Month`) * 30 as `Number of Days in Period`,
  YTD(sum(`Vendor Expenses`),`Report_Month`) as `YTD_Vendor Expenses`,
  (sum(`Total Accounts Payable`) / YTD(sum("Vendor Expenses"),"Report_Month") * (month(`Report_Month`) * 30) 
  FROM  apd_table  
  GROUP BY `groupkey`,
  `Report_Month`,
  `Total Accounts Payable`,
  `Total Income`
  </code></pre>
  
  <p>I'm looking for output like below:
  <a href="https://i.stack.imgur.com/QXFUp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QXFUp.png" alt="enter image description here"></a></p>
  
  <p>Please help me with this. Thank you.</p>