Sex selection or gender selection can be done through genetic studies on developing embryos before implantation or on sperm before being  introduced to  ovules The first option is performed through a technique called PGD, in which a biopsy is carried out on the embryos to later analyze their genetic load. The selection  sex through sperm is done by separating these depending on  their genetic makeup. 

WHY MAKE A SEX SELECTION? WHO DOES IT HELP?

Sex selection takes on greater relevance in the following cases

Family planning.

Prevent the birth of children who are affected or at risk of suffering from a sex-linked disease.