Hello,
I have a formula that counts distinct values within a range of columns.
However, I'm trying to figure out how to do the same thing when a Table column is filtered. I found a few examples online that work with a single column, just not a range of columns.
Unfiltered table shows a correct value for my distinct themes:
This filtered table still shows 11. If I can count only the visible cells in the filtered table, it would return 8.
Any help would be greatly appreciated…
I have a formula that counts distinct values within a range of columns.
Excel Formula:
=LET(
ThemeRng,t_MUs[[Theme A]:[Theme C]],
SUM(IF(ThemeRng <> "", 1 / COUNTIF(ThemeRng, ThemeRng), 0)))
However, I'm trying to figure out how to do the same thing when a Table column is filtered. I found a few examples online that work with a single column, just not a range of columns.
Unfiltered table shows a correct value for my distinct themes:
VBA Testing.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | Distinct Themes: | 11 | ||||||
2 | ||||||||
3 | ID | MU | Descriptive Code | Theme A | Theme B | Theme C | ||
4 | P1 | 33 | Random DC for MU 33 | 01 - Theme | 09 - Theme | 10 - Theme | ||
5 | P1 | 157 | Random DC for MU 157 | 01 - Theme | 03 - Theme | 11 - Theme | ||
6 | P1 | 176 | Random DC for MU 176 | 06 - Theme | 08 - Theme | |||
7 | P1 | 191 | Random DC for MU 191 | 06 - Theme | 07 - Theme | 10 - Theme | ||
8 | P2 | 89 | Random DC for MU 89 | 02 - Theme | 05 - Theme | |||
9 | P2 | 148 | Random DC for MU 148 | 03 - Theme | 04 - Theme | 10 - Theme | ||
10 | P2 | 181 | Random DC for MU 181 | 06 - Theme | 09 - Theme | |||
11 | P2 | 297 | Random DC for MU 297 | 01 - Theme | 09 - Theme | |||
Ct. Distinct |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D1 | D1 | =LET( ThemeRng,t_MUs[[Theme A]:[Theme C]], SUM(IF(ThemeRng <> "", 1 / COUNTIF(ThemeRng, ThemeRng), 0))) |
This filtered table still shows 11. If I can count only the visible cells in the filtered table, it would return 8.
VBA Testing.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | Distinct Themes: | 11 | ||||||
2 | ||||||||
3 | ID | MU | Descriptive Code | Theme A | Theme B | Theme C | ||
4 | P1 | 33 | Random DC for MU 33 | 01 - Theme | 09 - Theme | 10 - Theme | ||
5 | P1 | 157 | Random DC for MU 157 | 01 - Theme | 03 - Theme | 11 - Theme | ||
6 | P1 | 176 | Random DC for MU 176 | 06 - Theme | 08 - Theme | |||
7 | P1 | 191 | Random DC for MU 191 | 06 - Theme | 07 - Theme | 10 - Theme | ||
Ct. Distinct |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D1 | D1 | =LET( ThemeRng,t_MUs[[Theme A]:[Theme C]], SUM(IF(ThemeRng <> "", 1 / COUNTIF(ThemeRng, ThemeRng), 0))) |
Any help would be greatly appreciated…