Apr 28 2022 11:51 PM
How do we count date wise total invoices from the below table (without counting duplicates)
I have tried this formula =SUM(IF(FREQUENCY(C14:C24,C14:C24)>0,1)) but this gives total counts (excl duplicates) irrespective of date
Date | Inv Number |
24-04-2022 | 1 |
24-04-2022 | 2 |
24-04-2022 | 2 |
24-04-2022 | 2 |
25-04-2022 | 6 |
25-04-2022 | 88 |
25-04-2022 | 88 |
28-04-2022 | 54 |
28-04-2022 | 54 |
28-04-2022 | 59 |
28-04-2022 | 59 |
Apr 29 2022 12:55 AM
Apr 29 2022 01:54 AM
@Hans Vogelaar Thank you Hans Vogelaar. This gives me count of invoices, but not date wise?
Need to fill the below table (invoice count date wise)
Date | Count of inv |
24-04-2022 | ?? |
25-04-2022 | ?? |
28-04-2022 | ?? |
Data for filling the above table -
Date | Inv Number |
24-04-2022 | 1 |
24-04-2022 | 2 |
24-04-2022 | 2 |
24-04-2022 | 2 |
25-04-2022 | 6 |
25-04-2022 | 88 |
25-04-2022 | 88 |
28-04-2022 | 54 |
28-04-2022 | 54 |
28-04-2022 | 59 |
28-04-2022 | 59 |
Apr 29 2022 02:13 AM
A solution is to make sure you have access to Excel 365 and write the formula
= LET(
date, UNIQUE(sourceDate),
count, COUNTIFS(sourceDate,date),
HSTACK(date, count)
)
Apr 29 2022 02:29 AM
You could create a pivot table, adding the data to the Data Model:
You can then choose Distinct Count to summarize the Inv Number field:
Result:
Apr 29 2022 02:34 AM
Sorry, misread the question.
= LET(
distinctInv, UNIQUE(sourceData),
invDate, TAKE(distinctInv, ,1),
date, UNIQUE(sourceDate),
count, MAP(date, LAMBDA(d,
COUNT(IF(invDate=d, 1)))),
HSTACK(date, count)
)
Apr 29 2022 02:47 AM
=SUM(N(IF($A$5:$A$15=D7,MATCH(IF($A$5:$A$15=D7,$B$5:$B$15),IF($A$5:$A$15=D7,$B$5:$B$15),)=ROW($1:$11))))
An alternative could be this formula. Enter the formula with ctrl+shift+enter if you don't work with Office365 or 2021.
Apr 29 2022 03:49 AM
Apr 29 2022 07:20 AM
The array of dates and invoice numbers has 11 rows. If you select the MATCH or the ROW part of the formula and press F9 the results are shown in the formula bar. You can see them in the pictures in the attached file. The "then" part of the IF formula compares these results. You can return to the formula with ctrl+Z.
Apr 29 2022 02:30 PM
This is my way of understanding your approach. Range references always were meaningless to me so refactoring was a key element of my understanding a formula. I never could tell whether the result was more intelligible or whether it was simply that the refactoring process provided insight.
= LET(
recordNum, SEQUENCE(ROWS(sourceData)),
selectedDate?, sourceDate=@date,
selectedInvoice, IF(selectedDate?,invoice),
firstMatch, MATCH(selectedInvoice, selectedInvoice,),
SUM(N(IF(selectedDate?, firstMatch=recordNum))))
It wouldn't have been quite like this a year or two ago, but LET and LAMBDA are now so deeply engrained in my thought process, I almost forget how things used to be.
Apr 29 2022 07:44 PM
=SUM(--
(
FREQUENCY(
(A$14:A$24=D14)*B$14:B$24,
(A$14:A$24=D14)*B$14:B$24
) > 0
)
)-1
Apr 30 2022 03:09 AM
I have come to the conclusion that building the entire array of dates and counts in one formula overcomplicates things. So, given the distinct dates in a spilt range
= MAP(distinctDate#,
LAMBDA(d, COUNTA(
UNIQUE(FILTER(invoice, invoiceDate=d))
))
)
Apr 30 2022 04:58 AM
@Peter Bartholomew , @Shivashimladka
To illustrate @Hans Vogelaar solution I added it to the same file
Apr 30 2022 08:13 AM
Agreed that it is a good idea to demonstrate that the Pivot Table provides a realistic solution, and without requiring knowledge of formulas. The tabular format without subtotals is reasonably easy to emulate using array formulas but to include subtotals or table pivoting requires serious effort without the Pivot Table. I always get caught out by the need to refresh but, then, I haven't used Calculation Manual either.
Apr 30 2022 08:43 AM
I believe one day we will have out of the box DA formula for the aggregations. It's hard to compete with PowerPivot which has tens of years history, nonetheless. All depends on concrete case. Cube formulae in combination with dynamic arrays could be a compromise for today, but here we shall train our brains with MDX to generate more or less complex solution.
To refresh or not to refresh is always the question.
Aug 25 2022 07:38 AM
@Shivashimladka Can you help with counting these please? The data is in L3:L17
XCT22-2494-01
XCT22-2494-02
XCT22-2494-03
XCT22-2494-03
XCT22-2494-03
XCT22-2494-03
XCT22-2494-04
XCT22-2494-04
XCT22-2494-04
XCT22-2494-04
XCT22-2494-04
XCT22-2494-05
XCT22-2494-05
XCT22-2494-06
XCT22-2494-06
Aug 25 2022 07:44 AM
Do you want to count unique values?
If you have Excel 2021 or 365:
=COUNTA(UNIQUE(L3:L17))
If you have an older version, as an array formula confirmed with Ctrl+Shift+Enter:
=SUMPRODUCT(1/COUNTIF(L3:L17,L3:L17))
Aug 25 2022 07:50 AM
@Hans Vogelaar Awesome. Thank you