It isn't complicated. It requires knowing the molecular weight (also called molar mass) of the molecular compound, and the molecular weights (molar masses) of each of the atoms that reside within the compound, plus the counts of each atom within the molecular compound.
For CaCl2, the compounds (molecules) molecular weight is 110.984
For Ca++ the molecular weight is 40.078
For Cl- the molecular weight is 35.453
Such that: 1*40.078 + 2*35.453 = 110.984
Ratio to determine the quantities of each individual component within 10 grams:
Ca++ = 10 * 40.078/110.984
Ca++ = 3.611 grams
Cl - = 10 * (2*35.453)/110.984 [notice that you must multiply Cl times 2 since there are 2 atoms of Cl present]
Cl- = 6.389 grams
A quick proof check:
3.611 grams + 6.389 grams = 10 grams
Here is a great website to help you:
https://www.convertunits.com/molarmass/
When you launch this website, you simply enter the chemicals formula in the box and click on "Get molar mass". A lot of detailed information will follow that will be a great aid to you in your quest. Everything you need to determine individual component grams should be available through this website. All you need to know initially is the correct chemical formula. It should make your quest even easier than using the method I showed you above, as (among other things) it provides you with "mass percent". Multiply mass percent times your grams to get individual atoms weights in the compound as grams. Results will match my example above, but will be easier to do overall.