<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Accumulate Surplus and Deficit in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Accumulate-Surplus-and-Deficit/m-p/896366#M8075</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two files&amp;nbsp;&lt;A href="https://1drv.ms/u/s!AulZgdCGybPsiegpAb5iDJHHqC2Wdw?e=2NqLwy" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;the pbix file has two columns&lt;OL&gt;&lt;LI&gt;customer_id-patient_id-GPI10-dispense_index: this column serves as a dispense index. Each customer_id-patient_id-GPI10 values has n dispenses. The accumulated deficit needs to be calculated per customer_id-patient_id-GPI10&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Refill_Gap_PDC: this is the column that identifies a surplus or deficit per dispense.&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;The xlsx file is a sample calculation of what the final outcome should be in power bi with one&amp;nbsp;customer_id-patient_id-GPI10 example.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Let me know if you need anymore information.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hector M.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jan 2020 12:00:50 GMT</pubDate>
    <dc:creator>hmayol</dc:creator>
    <dc:date>2020-01-10T12:00:50Z</dc:date>
    <item>
      <title>Accumulate Surplus and Deficit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Accumulate-Surplus-and-Deficit/m-p/895725#M8064</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with transactions, each transaction has a "gap". The gap indicates either a surplus (positive gap) or a deficit (negative gap). I am trying to calculate the accumulated deficit.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The accumulated deficit depends on whether there is an accumulated surplus on the previous line to cover the current deficit or not.&amp;nbsp;&lt;UL&gt;&lt;LI&gt;Current surplus (gap) cannot be applied to previous deficit (accumulated)&lt;/LI&gt;&lt;LI&gt;Current deficit (gap) can only be offset by previous surplus (accumulated)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how I was able to achieve it in Excel:&amp;nbsp;&lt;/P&gt;&lt;P&gt;the formula for accumulated surplus =IF(C3+E2&amp;gt;0, 0, C3+E2)&lt;/P&gt;&lt;P&gt;the formula for accumulated deficit `=IF(C3&amp;lt;=0,D2,IF(AND(C3&amp;gt;0,C3+E2&amp;lt;0),D2,(C3+E2+D2)))&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;Gap&lt;/TD&gt;&lt;TD&gt;Accumulated Deficit&lt;/TD&gt;&lt;TD&gt;Accumulated Surplus&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&l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lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;-9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;-9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 03:31:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Accumulate-Surplus-and-Deficit/m-p/895725#M8064</guid>
      <dc:creator>hmayol</dc:creator>
      <dc:date>2020-01-10T03:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Accumulate Surplus and Deficit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Accumulate-Surplus-and-Deficit/m-p/896101#M8070</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="175668" data-lia-user-login="hmayol" class="lia-mention lia-mention-user"&gt;hmayol&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you provide some sample data and the expected result, so that I can help you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The information that you have provided is not clear. What is C3, E2 and D2. I think this are the cell references in the excel file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please provide sample data to understand your requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pavan Vanguri.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 09:04:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Accumulate-Surplus-and-Deficit/m-p/896101#M8070</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-01-10T09:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Accumulate Surplus and Deficit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Accumulate-Surplus-and-Deficit/m-p/896366#M8075</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two files&amp;nbsp;&lt;A href="https://1drv.ms/u/s!AulZgdCGybPsiegpAb5iDJHHqC2Wdw?e=2NqLwy" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;the pbix file has two columns&lt;OL&gt;&lt;LI&gt;customer_id-patient_id-GPI10-dispense_index: this column serves as a dispense index. Each customer_id-patient_id-GPI10 values has n dispenses. The accumulated deficit needs to be calculated per customer_id-patient_id-GPI10&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Refill_Gap_PDC: this is the column that identifies a surplus or deficit per dispense.&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;The xlsx file is a sample calculation of what the final outcome should be in power bi with one&amp;nbsp;customer_id-patient_id-GPI10 example.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Let me know if you need anymore information.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hector M.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 12:00:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Accumulate-Surplus-and-Deficit/m-p/896366#M8075</guid>
      <dc:creator>hmayol</dc:creator>
      <dc:date>2020-01-10T12:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Accumulate Surplus and Deficit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Accumulate-Surplus-and-Deficit/m-p/1041328#M13958</link>
      <description>&lt;P&gt;Hello!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you figure out a way to do this? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 08:43:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Accumulate-Surplus-and-Deficit/m-p/1041328#M13958</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-22T08:43:30Z</dc:date>
    </item>
  </channel>
</rss>

