(Cash_flow, optional Lowest, optional Highest) => let Lowest = if Lowest = null then -1 else Lowest, Highest = if Highest = null then 10000 else Highest, XIRRList = List.Generate( ()=> [Cash_flow=Table.Buffer(Cash_flow), Lowest=Lowest, Highest=Highest, Result=1, Counter=0, InterestRate=Lowest, DiffToPrevious=0.1], // Conditions determining if the next execution of the loop shall be performed each Number.Abs([Result])>=0.000000000001 and [Counter]<1000 and [DiffToPrevious]<>0, // loop command each [ // Binary-search procedure Lowest = if [Result]>0 then [InterestRate] else [Lowest], Highest= if [Result]<0 then [InterestRate] else [Highest], InterestRate = (Lowest+ Highest)/2, // Goal (formulated in a way that it should be null): Result= fnXNPV(Cash_flow, "CashFlow", "Dates", InterestRate), // Check if the result is still improving/changing DiffToPrevious = Result-[Result], Counter=[Counter]+1 ] ), Custom3 = List.Last(XIRRList)[InterestRate] in Custom3