I would rather pass the variable to the id
attribute inside the shortcode. You can even decide to remove the id
attribute inside the shortcode and make it a static value that you pass to your custom query
For examples and more info about how shortcodes operate, check out the Shortcode API