Get your taxes done using TurboTax

@taxes4739 

How to calculate earnings or losses
The IRS provides a specific formula — Net Income Attributable (NIA) — that must be applied to calculate earnings or losses attributable to an excess contribution.
Net Income = Excess to be removed x (Adjusted Closing Balance (ACB) – Adjusted Opening Balance (AOB))/
Adjusted Opening Balance (AOB)
Here’s how to determine the numbers to plug into the NIA formula: To determine the adjusted opening balance, add to the prior month end IRA balance all contributions (including the contribution creating the excess), consolidations, and transfers into the account since the contribution occurred. To determine the adjusted closing balance, subtract from the current value of the IRA all distributions, consolidations, and transfers in since the contribution occurred

 

here are a couple of examples:

Example 1

Linda, age 48, contributed $7,000 to her IRA last year. When filing taxes, she discovers she was eligible to contribute only $6,000. She requests to remove the $1,000 excess. Her IRA balance prior to the contribution was $22,000 and is now worth $31,750. She made no additional contributions or distributions. Her ACB is $31,750 and her AOB is $29,000 ($22,000 + $7,000). Linda will remove the $1,094.83 ($1000 excess contribution + $94.83 earnings attributable to the excess contribution).
$1,000 x ($31,750 - 29,000)/29000 = $1,000 x $2,750 / $29,000 = $94.83 NIA = $94.83 earnings 
Example 2
Zeke, age 62, contributed $7,000 to his IRA last year. When filing taxes, he discovers that due to his amount of earned income, he was only eligible to contribute $4,500. He requests to remove the $2,500 excess. His IRA balance prior to the contribution was $260,000 and is now worth $250,675. He made no additional contributions or distributions. His ACB is $250,675 and his AOB is $267,000 ($260,000 + $7,000). Zeke will remove $2,347.14 ($2,500 excess contribution - $152.86 loss attributable to the excess contribution).
$2,500 x ($250,675 - 267,000) / 267,000= $2,500 x -$16,325 / 267,000 = -$152.86 NIA 
source: https://www08.wellsfargomedia.com/assets/pdf/personal/goals-retirement/taxes-and-retirement-planning... 

 

the same formula applies to a ROTH

https://meetbeagle.com/resources/post/how-to-calculate-earnings-on-excess-roth-ira-contributions 

 

we have no way of knowing whether the amount you withdrew conforms to the above.