<?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: Goal Seeking the Rate of CAC Without Knowing the PMT and Rate in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946414#M97503</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="481216" data-lia-user-login="EddyW" class="lia-mention lia-mention-user"&gt;EddyW&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;yes, now we need a recursive iteration. The M-code could look like so:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// fnEIRofCUMIPMT
// fnEIRofCUMIPMT - returns annual effective interest rate, given total interest costs, PV and number of payment months
// Author: Imke Feldmann (www.TheBIccountant.com)

let
    Source = (CAC as number, Months as number, LoanAmount as number, optional Lowest_, optional Highest_, optional Precision_) =&amp;gt;

let

Lowest = if Lowest_ = null then 0 else Lowest_,
Highest = if Highest_ = null then 10000000000 else Highest_,
Precision = if Precision_ = null then 0.0001 else Precision_,

/* Debug parameters
Lowest = 0.001,
Highest = 0.1,
Precision = 0.0001,
 */

Result= List.Generate( ()=&amp;gt; [Lowest=Lowest, Highest=Highest, Result=1, Counter=0, Value=Highest, DiffToPrevious=0.1],

// Conditions determining if the next execution of the loop shall be performed

                    each Number.Abs([Result])&amp;gt;=Precision and [Counter]&amp;lt;1000 and [DiffToPrevious]&amp;lt;&amp;gt;0,
// loop command
                    each [                            
// Binary-search procedure
                            Lowest = if [Result]&amp;lt;0 then [Value] else [Lowest],
                            Highest= if [Result]&amp;gt;0 then [Value] else [Highest],
                            Value= (Lowest+ Highest)/2,  

// Helper function
                fnCUMIPMT_full = 
                (Rate as number, nPer as number, Pv as number, Type as number)  =&amp;gt;
                let
                    C = Number.Power((1+Rate),nPer),
                    Standard = (Pv* C) * - Rate / (C-1),
                    PMT = Standard / (1+Rate*Type),
                    _CUMIPMT_full = PMT * nPer + Pv
                in
                    _CUMIPMT_full,

// Goal (formulated in a way that it should be null):

                            Result= - CAC - fnCUMIPMT_full(Value, Months, LoanAmount, 0) ,

// Check if the result is still improving/changing

                            DiffToPrevious = Result-[Result],

                            Counter=[Counter]+1
                         ]
),
    Custom1 = List.Last(Result),
    AnnualRate = Custom1[Value]*12
in
    AnnualRate
in
    Source&lt;/LI-CODE&gt;
&lt;P&gt;Please also check file enclosed.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 04 Dec 2022 08:04:11 GMT</pubDate>
    <dc:creator>ImkeF</dc:creator>
    <dc:date>2022-12-04T08:04:11Z</dc:date>
    <item>
      <title>Goal Seeking the Rate of CAC Without Knowing the PMT and Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946380#M97494</link>
      <description>&lt;P&gt;Hello Everyone and &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1522" data-lia-user-login="ImkeF" class="lia-mention lia-mention-user"&gt;ImkeF&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding to this topic &lt;A href="https://community.powerbi.com/t5/Power-Query/Goal-Seek-to-Each-Row-for-Effective-Interest-Rate/m-p/2945901#M93044" target="_self"&gt;https://community.powerbi.com/t5/Power-Query/Goal-Seek-to-Each-Row-for-Effective-Interest-Rate/m-p/2945901#M93044&lt;/A&gt; , I would like to continue the case:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After the management know about the percentage of total cost of borrowing, the management of Company A wanted to know what is the equivalent Effective Interest Rate (EIR) of Cost of Acquistion Cost (CAC). FYI, Company A is engaged in fin-tech business. By knowing this, the company A might be aware and they will consider in determine the selling EIR to the consumer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can calculate on the case i have described by using Excel with goalseek property VBA (Attached). However, i don't know if it's possible to be done in PowerBI by only using RATE() Function. The reason is because i don't know the exact of PMT that is fulfill the %CAC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.google.com/spreadsheets/d/1vaxS1wUyZXvELv0Iof4i_0tLqNx-26P9/edit?usp=share_link&amp;amp;ouid=102880529565749557904&amp;amp;rtpof=true&amp;amp;sd=true" target="_self"&gt;Example EIR - Sent.xlsx&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only information i can give is :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Loan Tenure or Period of Loan&lt;/LI&gt;&lt;LI&gt;Loan Amount&lt;/LI&gt;&lt;LI&gt;CAC&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;Eddy W.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2022 05:12:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946380#M97494</guid>
      <dc:creator>EddyW</dc:creator>
      <dc:date>2022-12-04T05:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Goal Seeking the Rate of CAC Without Knowing the PMT and Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946414#M97503</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="481216" data-lia-user-login="EddyW" class="lia-mention lia-mention-user"&gt;EddyW&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;yes, now we need a recursive iteration. The M-code could look like so:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// fnEIRofCUMIPMT
// fnEIRofCUMIPMT - returns annual effective interest rate, given total interest costs, PV and number of payment months
// Author: Imke Feldmann (www.TheBIccountant.com)

let
    Source = (CAC as number, Months as number, LoanAmount as number, optional Lowest_, optional Highest_, optional Precision_) =&amp;gt;

let

Lowest = if Lowest_ = null then 0 else Lowest_,
Highest = if Highest_ = null then 10000000000 else Highest_,
Precision = if Precision_ = null then 0.0001 else Precision_,

/* Debug parameters
Lowest = 0.001,
Highest = 0.1,
Precision = 0.0001,
 */

Result= List.Generate( ()=&amp;gt; [Lowest=Lowest, Highest=Highest, Result=1, Counter=0, Value=Highest, DiffToPrevious=0.1],

// Conditions determining if the next execution of the loop shall be performed

                    each Number.Abs([Result])&amp;gt;=Precision and [Counter]&amp;lt;1000 and [DiffToPrevious]&amp;lt;&amp;gt;0,
// loop command
                    each [                            
// Binary-search procedure
                            Lowest = if [Result]&amp;lt;0 then [Value] else [Lowest],
                            Highest= if [Result]&amp;gt;0 then [Value] else [Highest],
                            Value= (Lowest+ Highest)/2,  

// Helper function
                fnCUMIPMT_full = 
                (Rate as number, nPer as number, Pv as number, Type as number)  =&amp;gt;
                let
                    C = Number.Power((1+Rate),nPer),
                    Standard = (Pv* C) * - Rate / (C-1),
                    PMT = Standard / (1+Rate*Type),
                    _CUMIPMT_full = PMT * nPer + Pv
                in
                    _CUMIPMT_full,

// Goal (formulated in a way that it should be null):

                            Result= - CAC - fnCUMIPMT_full(Value, Months, LoanAmount, 0) ,

// Check if the result is still improving/changing

                            DiffToPrevious = Result-[Result],

                            Counter=[Counter]+1
                         ]
),
    Custom1 = List.Last(Result),
    AnnualRate = Custom1[Value]*12
in
    AnnualRate
in
    Source&lt;/LI-CODE&gt;
&lt;P&gt;Please also check file enclosed.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2022 08:04:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946414#M97503</guid>
      <dc:creator>ImkeF</dc:creator>
      <dc:date>2022-12-04T08:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Goal Seeking the Rate of CAC Without Knowing the PMT and Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946435#M97513</link>
      <description>&lt;P&gt;Hello &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1522" data-lia-user-login="ImkeF" class="lia-mention lia-mention-user"&gt;ImkeF&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for the M-Code. It really helps me a lot! But i have a problem here. When i tried to put this M-Code into PowerBI, it said that i have to &lt;STRONG&gt;"switch all tables to Import Mode"&lt;/STRONG&gt; (FYI, i'm in DirectQuery mode). Is it possible to get this M-Code running under DirectQuery Mode?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Eddy W.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2022 09:20:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946435#M97513</guid>
      <dc:creator>EddyW</dc:creator>
      <dc:date>2022-12-04T09:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Goal Seeking the Rate of CAC Without Knowing the PMT and Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946449#M97515</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="481216" data-lia-user-login="EddyW" class="lia-mention lia-mention-user"&gt;EddyW&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Sorry, but I don't think so, as this is true recursion.&lt;BR /&gt;By choosing Direct Query Mode you are limiting yourself to only basic transformations:&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-directquery-about#modeling-limitations" target="_blank"&gt;Using DirectQuery in Power BI - Power BI | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2022 09:56:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946449#M97515</guid>
      <dc:creator>ImkeF</dc:creator>
      <dc:date>2022-12-04T09:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Goal Seeking the Rate of CAC Without Knowing the PMT and Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946563#M97522</link>
      <description>&lt;P&gt;Hello &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1522" data-lia-user-login="ImkeF" class="lia-mention lia-mention-user"&gt;ImkeF&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Noted that. Your information is clear and concise. Thank you &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Eddy W.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2022 14:23:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Goal-Seeking-the-Rate-of-CAC-Without-Knowing-the-PMT-and-Rate/m-p/2946563#M97522</guid>
      <dc:creator>EddyW</dc:creator>
      <dc:date>2022-12-04T14:23:56Z</dc:date>
    </item>
  </channel>
</rss>

