You need 3 pieces of information; the molecular weight of the chemical, its molecular formula, and the atomic weight of the particular element. For potassium dichromate these are 294.2 g/mole, K2Cr2O7, and 52 g/mole. Using this information you calculate the percentage of chromium in a molecule of potassium dichromate, 2 atoms of Cr in potassium dichromate x 52 g/mole / 294.2 g/mole = 35.35%. Continuing with your example you then multiply the percentage times the total weight, 35.35% x 40 g = 14.14 g. Dissolve 40 g of potassium dichromate in a liter of water and 100 ml of this solution will contain 100 ml/1000 ml/l x 14.14 g/l = 1.414 g of chromium.
For potassiuum ferricyanide the only change would be to use the molecular weight of the cyanide ion which is equal to the sum of the weights of the two elements carbon and nitrogen. The rest of the calculation should be obvious. BTW there is NO free cyanide in potassium ferricyanide as it is all tightly bound to the iron atom. So this calculation is rather meaningless.
The molecular weight and formula can be obtained from the MSDS for the compound, the atomic weight from the Periodic Table.