Miscarriage or No??

Went for pregnancy confirmation last week (9/12/18) urine Sample and Blood work both came back positive, however the Sonogram showed no gestational sac. The doctor said I could just be really early or it could be a chemical pregnancy and explained miscarriage. I started to have mild bleeding the very next day for about 2 days, spotting for 1 day after that, then brown spotting to nothing as of yesterday. I went in for a sonogram today and the gestational sac could be seen and measured at 5 weeks. She still told me I was having a miscarriage due to my HCG numbers being 604. How is it possible to not see a sac one week then progress to a sac but still be miscarrying...wouldn't the sac never be created? Im so confused am I miscarrying or not? Has this happened to anyone else?