How to determine how much foreign tax qualified for foreign tax credit?

My situation is complex.  I file tax form with my wife together.  We live in a foreign country, I have incomes from different sources, A, B, and C, my wife have sole incomes from D.  I paid foreign tax for A and B at different tax rate, but no tax for C, my wife paid foreign tax for D.  Part of my total incomes is excluded as the foreign earned income and foreign housing exclusions, and all my wife's incomes is excluded.  I know I can only take foreign tax credit for the foreign tax paid for those incomes not excluded.  

How to determine how much tax is for those not excluded incomes?  How do I know the excluded incomes are for A, B, or C? Can I choose A or C as excluded incomes since their tax rate is lower, and B as not excluded income?  Or the total tax I paid divided by all my incomes then multiplied by the incomes not excluded? or  the total tax my wife and I paid divided by all our incomes then multiplied by the incomes not excluded? 

Thanks a lot!