This will tell you at what level your cell is in the pivot table structure. So In your example where you have two dimensions the cells you wish to hide will have dimensionality > 1. So you can write your expression like this:
as the pivot recalculates the expression on total lines the Total will appear whereas the other cells will be blank.
If you have more dimensions you will have to tweak the condition set on dimensionality().