You can probably achieve this by combining the logic of your two expressions.
Say you have a simple DataSet and a simple Tablix based on this:


Here RowNum is calculated as:
=RunningValue(Fields!val1.Value, CountDistinct, "Tablix1")
Next, hide some lines using an expression based on two other fields:
=IIf(Fields!val2.Value + Fields!val3.Value <> 0, False, True)

This breaks the RowNum, but we can change the expression to ignore hidden lines. We do this with NULLing out (i.e., for SSRS set to Nothing ) - CountDistinct will not consider Nothing values:
=RunningValue(IIf(Fields!val2.Value + Fields!val3.Value <> 0, Fields!val1.Value, Nothing) , CountDistinct , "Tablix1")
Now RowNum ignores hidden strings as necessary:

source share