<?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: factor cumulative balance for different relationship manager in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/factor-cumulative-balance-for-different-relationship-manager/m-p/3429972#M130009</link>
    <description>Thank you for the solution but it is not coming properly. The values are coming as negative.</description>
    <pubDate>Thu, 14 Sep 2023 05:14:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-09-14T05:14:37Z</dc:date>
    <item>
      <title>factor cumulative balance for different relationship manager</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/factor-cumulative-balance-for-different-relationship-manager/m-p/3426168#M129814</link>
      <description>&lt;P&gt;I have three table named balance, datetable, rm mapping and rm master in power bi. Balance have disbursement and collection amount based on clients and it has dates also. Datetable is a calendar table . Rm master has unique rm names and codes. Rm mapping table has rm names for clients and last change date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Rm mapping table some clients were assigned to one relationship manager previously and now are assigned to different relationship manager(rm).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now we want to calculate cumulative balance(disbursement -collection) based on dates from datetable table .we want that if suppose rm a had client b till March and now rm c is assigned to client b , balance for b will show for rm a till march and then from april balance for b will show for rm c but march values will add on april and so on as the calculation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We need to create a measure in power bi to calculate the balance.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 11:10:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/factor-cumulative-balance-for-different-relationship-manager/m-p/3426168#M129814</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-09-12T11:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: factor cumulative balance for different relationship manager</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/factor-cumulative-balance-for-different-relationship-manager/m-p/3426854#M129854</link>
      <description>&lt;P&gt;&lt;SPAN&gt;This measure will take into account the disbursement and collection amounts, the date of change in RM assignment, and the date for which you want to calculate the cumulative balance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This measure assumes that your 'Balance' table has a column named 'ClientID', 'Disbursement', and 'Collection'. Replace these with your actual column names&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Cumulative Balance = 
VAR CurrentDate = MAX('DateTable'[Date])
VAR CurrentClients = VALUES('Balance'[ClientID])
RETURN
SUMX(
    CurrentClients,
    VAR CurrentClient = [ClientID]
    VAR LastRMChangeDate = CALCULATE(MAX('RM Mapping'[Last Change Date]), 'RM Mapping'[ClientID] = CurrentClient)
    VAR CurrentRM = CALCULATE(MAX('RM Mapping'[RM Name]), 'RM Mapping'[ClientID] = CurrentClient, 'RM Mapping'[Last Change Date] &amp;lt;= CurrentDate)
    VAR Disbursement = CALCULATE(SUM('Balance'[Disbursement]), 'Balance'[ClientID] = CurrentClient, 'Balance'[Date] &amp;lt;= CurrentDate, 'RM Mapping'[RM Name] = CurrentRM)
    VAR Collection = CALCULATE(SUM('Balance'[Collection]), 'Balance'[ClientID] = CurrentClient, 'Balance'[Date] &amp;lt;= CurrentDate, 'RM Mapping'[RM Name] = CurrentRM)
    RETURN
    Disbursement - Collection
)&lt;/LI-CODE&gt;&lt;P&gt;Explanation:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;CurrentDate&lt;/STRONG&gt;: Fetches the maximum date from your 'DateTable', which should be the date for which you want to calculate the cumulative balance.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;CurrentClients&lt;/STRONG&gt;: Creates a table of unique client IDs present in the 'Balance' table.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;LastRMChangeDate&lt;/STRONG&gt;: For each client, fetches the last date when the RM was changed.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;CurrentRM&lt;/STRONG&gt;: Determines the RM assigned to the client as of the current date.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Disbursement and Collection&lt;/STRONG&gt;: Calculates the total disbursement and collection for each client up to the current date, considering the RM assigned to them.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;SUMX&lt;/STRONG&gt;: Iterates over each client to calculate the cumulative balance (Disbursement - Collection).&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 12 Sep 2023 17:01:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/factor-cumulative-balance-for-different-relationship-manager/m-p/3426854#M129854</guid>
      <dc:creator>MargusMartsepp</dc:creator>
      <dc:date>2023-09-12T17:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: factor cumulative balance for different relationship manager</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/factor-cumulative-balance-for-different-relationship-manager/m-p/3429972#M130009</link>
      <description>Thank you for the solution but it is not coming properly. The values are coming as negative.</description>
      <pubDate>Thu, 14 Sep 2023 05:14:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/factor-cumulative-balance-for-different-relationship-manager/m-p/3429972#M130009</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-09-14T05:14:37Z</dc:date>
    </item>
  </channel>
</rss>

