Fitlering doesn't work when <Template> is used in DataGrid

Filtering will work on Data by defined Property, not by what’s displayed in a template. You might need to extend your model with a new property that will return the value similar to the template logic and use this property for filtering.