Gotcha. I won't even touch the consumer side, because I don't know much about it.

On the business side... it's not possible to do justice to this topic in a HN post. Books could be (and have been) written on this. But I can share a few thoughts.

If you're selling in the US (or really, North America) the following applies. If not, similar ideas probably apply in other countries.

1. Look at the NAICS codes[1] as a possible starting point for how to segment your potential customers.

2. There is Census Bureau data on how many companies there are and how big they are, in the various categories. Using this could give you the earliest "rough cut" of a total market size

3. Read The Four Steps to the Epiphany for more on how to drill in and learn more about specific customers / industries, and start finding prospective initial customers.

4. Beyond the Gartner / Forrester / etc. reports, there are some generic industry survey / report things "out there". I can't remember the names off-hand, but several of those things are in the "would ordinarily cost big money" category, BUT can often times be accessed from your local library for free.

5. Dun & Bradstreet bought out the company that used to be Hoovers, who offered a relatively cheap ($99 / month or so) subscription to their services which included all sorts of industry information, surveys, and the like, in addition to detailed contact info for (many) individuals. I think D&B killed off Hoovers and rebranded / repackaged it and I don't know how much the equivalent offering (if there even is one) costs now, but it might not hurt to call them up and say "What do you have now that's like the old Hoovers product, and how much does it cost?". If you can afford it, you might find that useful.

6. There's a lot of additional data available from govt sources that you can probably use to help you get ideas about your market. Poke around the various sites like Bureau of Labor Statistics, Bureau of Economic Anlysis, the SUSB (Statistics of U.S. Businesses) stuff, etc. You'll have to be creative in terms of figuring out how to use this to infer things about the market(s) you want to sell to.

All of this will get you a rough idea of the approximate market size, but be wary of your assumptions. If you say, for example, to yourself "We will sell to companies in NAICS codes 14, 23, and 97, and that represents 398,244 companies that have an average spend for our product category of $100,000 / year" and you do the math and say "that's our market", then you will have problems. That's where the Four Steps stuff comes in, and actually talking to people. "Get out of the building" as Steve Blank says. Why? Because it's almost inevitable that you will find that not all (or even most) "companies in NAICS code 14, that spend $100,000 / year on IT solutions" will be interested in what you are pitching.

Anyway, that's an extremely superficial overview of some ways you can get at least a ballpark idea of market size for some B2B scenarios. Consumer, again, is a different ballgame in many ways and I'll refrain from even trying to comment on that. I guess the only other thing I'd add is go to Amazon.com, look up a couple of books on "market research" that have cheap used copies available, and order a couple of run through them.

[1]: https://www.census.gov/NAICS