How to use a nested shortcode to render the value of an attribute in parent shortcode

I decided to modify the custom shortcode to make it a wrapper for the parent shortcode. Instead of returning a value, it now returns a call (using do_shortcode()) to the parent with its “to” attribute dynamically set.

OLD VERSION

...
$val = get_some_value();
return $val;

NEW VERSION

...
$val = get_some_value();
return do_shortcode("[ut_count_up to=\"$val\"]");