You can re-characterize a measure as a dimension (just drag it from Measures to Dimensions -- or, if you want to keep them as measures, create duplicate fields for A and B and then use those as dimensions). Then you can create two sets for the null values and then combined set(s) to do the desired analysis.
This doesn't make sense to me. I don't need it to be dynamic as a parameter is. But I think Joshua's answer will work.
What doesn't make sense? Parameters are not dynamic.
But yes, in your case, Joshua's solution may be best. Parameters can leverage very complex calculations.