Here’s a possible reason, based on info in the Microsoft online DAX function documentation on SUBSTITUTE:
This DAX function may return different results when used in a model that is deployed and then queried in DirectQuery mode. For more information about semantic differences in DirectQuery mode, see https://go.microsoft.com/fwlink/?LinkId=219171.
As a potential fix, try using the REPLACE function instead of SUBSTITUTE and see if that solves the problem.