=SUMPRODUCT((D12:D241<>"")/COUNTIF(D12:D241,D12:D241&""))

Now, there are a couple of manipulations I'd like to make. First, how can I successfully add the SUBTOTAL command to this formula so that when the list is filtered, the calculation uses only the data shown?

Next, how do I then take that formula and add other criteria to the equation. For example, with the formula above I have the number unique entries in column D. The next portion of my post would then update that number when the list is filtered. Finally, how could I then derive the number of these entries also containing data in column T? By adding...

,--($T$12:$T$241<>"")

or something similar to the SUMPRODUCT command?

Thanks as always.