You would normally filter out items in a list within a datasource webpart or repeater webpart that you are using. The transformation should really only be your presentation layer.
Most likely you have a repeater though. You can add into the WHERE Condition property something like this:
('{%ToInt(tagid, "")%}' = 0 AND '{%tagname%}'='') OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentTag WHERE TagID = {% ToInt(tagid) %}))
That filters our blog posts by tags.
{%tagid%}
is a query string macro to pull in the variable.
If you are passing around a CategoryID value in the URL can modify from tagid to CategoryID but you would have to change the SQL WHERE clause to look at Document Category not DocumentTag