top of page
Writer's pictureAhmed Sulaiman

๐Ž๐ฉ๐ญ๐ข๐ฆ๐ข๐ณ๐ข๐ง๐  ๐‹๐จ๐š๐ง ๐ˆ๐ง๐ญ๐ž๐ซ๐ž๐ฌ๐ญ ๐‚๐š๐ฅ๐œ๐ฎ๐ฅ๐š๐ญ๐ข๐จ๐ง๐ฌ ๐€๐œ๐ซ๐จ๐ฌ๐ฌ ๐Œ๐ฎ๐ฅ๐ญ๐ข๐ฉ๐ฅ๐ž ๐‘๐š๐ญ๐ž ๐๐ž๐ซ๐ข๐จ๐๐ฌ ๐ข๐ง ๐๐จ๐ฐ๐ž๐ซ ๐๐ˆ:

Precise interest calculations are essential for financial analysis, particularly when loans extend across periods with varying reference rates.ย A recent challenge in Power BI involving such calculations was resolved by implementing a solution using DAX measures and calculated tables to ensure accuracy, addressing discrepancies encountered with simpler approaches.


๐๐ซ๐จ๐›๐ฅ๐ž๐ฆ ๐’๐ญ๐š๐ญ๐ž๐ฆ๐ž๐ง๐ญ:

I manage two primary datasets in Power BI:


ReferenceRates Table:

ย ย ย | Date ย  ย  ย  | Rate ย  |

ย  ย |------------|----------|

ย  ย | 3/23/2016 ย | 1.20% ย |

ย  ย | 4/27/2016 ย | 1.05% ย |

ย  ย | ... ย  ย  ย  ย  | ... ย  ย  |

ย  ย | 9/25/2024 ย | 6.50% ย |


Loan Table:

| Company ย  | Partner ย  | Date ย  ย  ย | Loan Amount | Number of Days |

ย  ย |-----------|-----------|-----------|-------------|-----------------|

ย  ย | Company A | Project X | 5/15/2024 | 1,968,000 ย  | 117 ย  ย  ย  ย  ย  ย  |

ย  ย | Company A | Project X | 9/9/2024 ย | 2,964,000 ย  | 22 ย  ย  ย  ย  ย  ย  ย |

ย  ย | Company A | Project X | 10/1/2024 | -20,000,000 | ย  ย  ย  ย  ย  ย  ย  ย  |


Initial Issue:

When a loan spans multiple rate changes, the interest calculations were inaccurate due to improper segmentation. Specifically, a loan starting onย 5/15/2024ย with the next loan event onย 9/9/2024ย underwent three rate changes:

5/22/2024:ย 7.25%

6/19/2024:ย 7.00%

7/24/2024:ย 6.75%


Solution Process:

To achieve accurate interest calculations, I undertook a structured approach leveraging Power BI's data modeling and DAX capabilities:


Segmenting Rate Periods:

RatePeriods Table:ย I created a calculated table to define each interest rate's effective start and end dates. This segmentation allowed me to identify the precise periods during which each rate was applicable.


Defining Loan Durations:

LoanPeriods Table:ย Another calculated table was established to determine each loan's active period by identifying the start date and calculating the end date based on subsequent loan events for the same company and partner.


Mapping Loans to Rate Periods:

LoanRatePeriods Table:ย By cross-joining theย LoanPeriodsย andย RatePeriodsย tables, I identified overlapping periods where specific rates applied to particular loan durations. This segmentation was crucial for ensuring that each portion of the loan was accurately attributed to the correct interest rate.


Finally, DAX measures were created to calculate loan amounts at each period start, cumulative loan amounts, applicable rate durations, and interest for each period segment, accounting for both rate and loan event changes.ย This resulted in a final table accurately reflecting each loan segment with precise interest calculations, improving financial reporting accuracy and providing a detailed interest computation breakdown across varying rate periods.




20 views0 comments

Comments


bottom of page