My formula (about distinct count) in C2 works but slow when many rows, any idea to speed it up? Formula in D2 does not provide the correct value...

ED38

New Member
Joined
Mar 29, 2024
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Book4
ABCD
1Product CodeFiscal Year Quarterunique Quarter the product has been soldColumn1
2A2025 Q277
3B2025 Q287
4C2025 Q277
5A2025 Q177
6B2025 Q187
7C2024 Q176
8B2024 Q187
9C2023 Q177
10A2023 Q177
11B2024 Q287
12C2024 Q277
13A2023 Q277
14C2023 Q277
15B2024 Q387
16A2024 Q377
17C2023 Q377
18B2023 Q387
19A2024 Q4 76
20A2024 Q4 76
21C2023 Q4 77
22B2023 Q4 87
23A2024 Q177
24C2024 Q176
25B2023 Q187
26Correct but slow!Incorrect but fast!
Sheet1
Cell Formulas
RangeFormula
C2:C25C2=COUNTA(UNIQUE(IF([Product Code]=[@[Product Code]],[Fiscal Year Quarter],"")))-1
D2:D25D2=COUNTIFS([Product Code],[@[Product Code]],[Fiscal Year Quarter],"<>"&[@[Fiscal Year Quarter]])
 
How about
Excel Formula:
=ROWS(UNIQUE(FILTER([Fiscal Year Quarter],[Product Code]=[@[Product Code]])))
 
Upvote 0
Solution
Hi Fluff,

thank you for the proposal : I thought it was simpler, obvious (afterwards!) and probably fast but trying it I have been surprised to see a column of "#VALUE!" errors (after a while).
maybe does not work within a table or...?
Any other idea?
Thanks again
 
Upvote 0
I have been surprised to see a column of "#VALUE!" errors (after a while)
That does not happen with the sample data above so could you give us a smallish set of sample data with XL2BB where that does happen?
 
Upvote 0
Sorry, my mistake, I wrongly copied the formula provided by Fluff. It does work!
and performance are improved : calculation time dropped from 6:45' to 3:27' about 200 seconds faster!
thank you again
 
Upvote 0

Forum statistics

Threads
1,226,837
Messages
6,193,254
Members
453,784
Latest member
Chandni

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