The Kalmar Union is hard to keep - Sweden-Finland's interests were so much different from the interests of Denmark-Norway. The Danish nobility and the German noblemen and mercenaries the Danish Kings usually rewarded by making them tax collectors in Sweden had no understanding of the rights of the free-holding Swedish peasants, a cause for the multiple, sometimes even yearly revolts in Sweden.
While Denmark and a Hansaetic Legue can be at odds and usually were, the Hansaetic Legue and Swedish rebels have common interests. Sweden provides tar and wood for shipping, vital resources for the Legue, while the Legue transports the vital salt for Sweden. The Legue is sure to support Swedish revolts against Denmark to weaken them, and I don't see how Denmark really can hold on to Sweden - they were unable to do it OTL in the same scenario.
To keep the Hansaetic Legue powerful, you probably need to have it dominate north sea trade - you need to nerf the English and probably have the Dutch join the Legue rather than take over its trade. The problem is that the Dutch have conflicts with the Habsburgs, somehting the Legue has no profit in partaking in, and the Legue's conflicts with Denmark (and perhaps Novgorod or Muscowy over Baltic ports) is of no interest to the Dutch - they just want tar, hemp and wood from Sweden and grain from the Baltics (so they can continue to grow cash crops themselves) to flow uninterrupted.
You need a series of strong Danish Kings with the finesse to accept Swedish peasants' rights and a common enemy of Sweden and Denmark (an über-Novogorod wanting to make them all orthodox? Probably ASB). At the same time you need to make the Hansaetic Legue far more powerful to be able to resist the centralising Scandinavian countries as well as the German princes wanting to expand their power. You also need to make sure they are not out-competed by the English and the Dutch. A hard task indeed.