1
votes

I need to count unique values [Name1] with a given category [Category1] that are only present when their corresponding variables [Number1] are the minimum available when referencing another table that shares a category [Category2,Number2]. Table1 has fixed variables, whereas Table2 has independent variables--hence the need to reference it. Thus, the binary value of the unique value/row for [@Name1] depends on whether [@Number1] meets the minimum threshold from [@Number2] given matching categories. Therefore, the #of unique values should scale with the input for each category.

Example

    Table1      
Name1   Category1.. Number1
Alpha   One          0.00
Alpha   One         25.00
Alpha   One         50.00
Beta    Two         20.00
Beta    Two         40.00
Beta    Two         60.00
Beta    Two         80.00
Beta    Two        100.00
Gamma   Two         35.00
Gamma   Two         70.00
Epsilon Three       30.00
Epsilon Three       60.00
Epsilon Three       90.00

    Table2  
Category2   Number2
One           25.00
Two           30.00
Three         20.00

Here, [Category]:One should have 1 UV, [Category]:Two should have only 1 UV, and [Category]:Three should have 0 UV

I have tried various formulae, but I am stumped on how to account for all the criteria and two tables.

If it is not too much to ask, please include an equation not just for Total UV, but broken by category as well. Table1 also has to be read in any order, but Table2 does not.

2

2 Answers

1
votes

In short, you are looking for a 'count unique' of the values in Name1 that correspond to a Category1 match with Category2 and also have a Number1 that is 'less than' the cross-referenced threshold in Number2.

    Count Unique with multiple conditions

The formula in I34 is,

=SUMPRODUCT(((Table1[Category1]=H3)*(Table1[Number1]<SUMIF(Table2[Category2], H3, Table2[Number2])))/(COUNTIFS(Table1[Name1], Table1[Name1]&"", Table1[Number1], "<"&SUMIF(Table2[Category2], H3, Table2[Number2]))+(((Table1[Category1]<>H3)+(Table1[Number1]>=SUMIF(Table2[Category2], H3, Table2[Number2]))))))

That translates to a non-structured table formula of,

=SUMPRODUCT(((B$3:B$15=H3)*(C$3:C$15<SUMIF(E$3:E$5, H3, F$3:F$5)))/(COUNTIFS(A$3:A$15, A$3:A$15&"", C$3:C$15, "<"&SUMIF(E$3:E$5, H3, F$3:F$5))+(((B$3:B$15<>H3)+(C$3:C$15>=SUMIF(E$3:E$5, H3, F$3:F$5))))))

Fill down as necessary.

0
votes

I seriously doubt I understand the requirement but note that, assuming Name1 is in A1 and Table 2 is a named range CatTable then a PivotTable which includes D2 (copied down) of:

=N(VLOOKUP(B2,CatTable,2,0)>C2)  

with Category1.. for ROWS and the formula column label for Sum of VALUES returns:

One    1  
Two    1  
Three  0