Count Distinct Unique values with nested IFs Formula

Novice86

New Member
Joined
Jul 18, 2015
Messages
13
I'm looking for a formula to count distinct values in column E (Order Numbers) if they are on a specific date in column M and if the orders are complete, or have zero left to build, meaning column R values are equal to zero.

I've used =SUMPRODUCT((Data!E2:E6000<>"")/COUNTIF(Data!E2:E6000,Data!E2:E6000&"")) to generate a list of all distinct order numbers but now cannot figure out how to incorporate a date and are complete.

Can anybody help?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Here is a UDF that should do the trick. This code assumes that you have data from columns A to R. It can be adjusted if needed.

Code:
Function TOTALUNIQUE(r As Range, dt As Date) As DoubleDim AL As Object: Set AL = CreateObject("System.Collections.ArrayList")
Dim AR() As Variant: AR = r.Value
Dim tmp As String


For i = LBound(AR) To UBound(AR)
    If AR(i, 13) = dt And AR(i, 18) = 0 Then
        tmp = AR(i, 5) & "|" & AR(i, 13)
        If Not AL.contains(tmp) Then AL.Add tmp
    End If
Next i


TOTALUNIQUE = AL.Count
End Function

and the formula would look like
Code:
=TOTALUNIQUE(A2:R7,DATE(2019,8,9))

Don't include the header row in the first argument.

I have PowerQuery and PivotTable solutions as well.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top