Basics
Illustrator is a vector program and it is resolution independent. (E.g. If you create an artwork on an Artboard of 300 x 200 pixels, you can export your artwork at 3000 x 2000 without loosing quality.
Short Answer to your question
Whenever you want to export an image (JPG, PNG etc), always use Save for web. Or save for screens.
File > Export > Save for Web (Legacy) > Image Size
If you have different size of artboard in (pixels) than your desired image size, you have two options.
- Scale up/down the artboard with artwork.
- Use File > Export > Save for Web (Legacy) > Image Size
Explanation
If you are producing an artwork for digital medium (Web, App etc), you are not dependant on ppi settings. Always use pixels as document units
and use Export for Web Dialog box. So even if you want a different size (in percent or pixels) you can do it easily.
You can change your units from Document Setup OR Artboard Settings.
If you are working for a print medium (Printed Ad, Catalog etc), use metric or imperial system units (inch, centimeter, millimeter etc) and always send artwork in vector format. (AI, PDF etc).
Why use File > Export > Export As (set ppi)
Metric or imprerial system units depends on ppi factor before converting to pixel units.
One purpose of Export to JPEG dialog (File > Export > Export As) is to create a preview before sending artwork to print (Where exact number of pixels is not important).
Examples:
If you have a large artwork, say 40" 60" and you want to creat a preview image, don't try to use save for web or your computer will try to calculate your artwork in pixels and apply the default export algorithm and would take forever to respond because it makes the process very heavy to compute.
Rather use File > Export > Export As and use a smaller ppi (e.g 12, 15).
Similarly, if there is a smaller artwork (3" x 2", a Price tag or something) and you want to create a JPEG preview you can achieve an adequate size by setting the ppi to 300.
If the size of your artboard is the same in Pixels as your desired image size, using 72 ppi in the export dialog will produce the same number of pixels. If you want double the pixels, use 144. Use 72 as the scale factor of your desired image size in pixels.