Google Sheets formula only showing some duplicates, not all of them - duplicates

I have a custom formula in my Google Sheet to find any duplicates in column A;(reference numbers)
=countif(A:A,A3)>1
I've also tried =COUNTIF($A$3:$A,A3)>1
The range is A3:A2199 as there are headers in rows 1 & 2
The formula however does not seem to pick up all the duplicated reference numbers, only some of them.
Is it possible to show me where i'm going wrong?
Many thanks,
Cat

This formula will give you all duplicates
=sort(unique(filter(A3:A2199, COUNTIF(A3:A2199, A3:A2199)>1)))

Related

How to count unique values that are present in 2 different sheets only if they exist in both sheets

[Goal]
I want to be able to count unique values that are present in 2 different sheets only if they exist in both sheets.
[Details]
First, there are 2 sample data sheets (Data A, Data B) within the same Spreadsheet and it also has a sample dashboard to do the calculations. One thing to note about the data sheets is that they have different ranges, so they have different number of columns and rows. However, a couple things they have in common are the Month and ID columns.
Next, in the Dashboard sheet, there are 3 cells where B3 is the Month selector, C3 is to count the number of unique IDs that are included in both sheets (Data A & Data B) based on the month. With D3, I would like to count the number of unique IDs that are included in both sheets (Data A & Data B) where the the Month are the same AND Data B sheet's Cumulative column is 1.
[What I tried so far]
I tried using the COUNTUNIQUEIFS function and had the range as an array (by using the curly bracket) in the below way, however, it didn't work.
=COUNTUNIQUEIFS('Data A'!$B:$B,'Data A'!$A:$A,B3,'Data B'!$A:$A,B3)
I also tried without making the range argument an array.
=COUNTUNIQUEIFS('Data A'!$B:$B,'Data B'!$A:$A,B3)
Both attempts results in 1 for February 2023 when it should return 2. The weird thing is that January 2023 should return 3 and it correctly returns 3.
Hope someone can help me out with this. If there's a more elegant solution to achieve this by using Google Apps Scripts, I'd like to see hear about that as well.
You can try filtering both ranges for month, and the FILTER again by comparing them with MATCH and counting the remaining results:
=LAMBDA(ar,br,COUNTA(IFERROR(FILTER(ar,NOT(ISERROR (MATCH(ar,br,0))))))
(FILTER('Data A'!B:B,'Data )A'!A:A=B3),FILTER('Data B'!B:B,'Data B'!A:A=B3))
And just add an additional filter for the next column and the cumulative =1 'Data B'!C:C=1
=LAMBDA(ar,br,COUNTA(IFERROR(FILTER(ar,NOT(ISERROR (MATCH(ar,br,0)))))) (FILTER('Data A'!B:B,'Data )A'!A:A=B3),FILTER('Data B'!B:B,'Data B'!A:A=B3,'Data B'!C:C=1))

Can I show the results of COUNTIF in one column only if there is data in another column?

I have a spreadsheet with multiple sheets.
Sheet A is generated from a template, and it is where users will enter in data to be formatted into a report; it will be deleted after that report is submitted.
As people enter info into Column A of Sheet A, they don't have to enter client information if we already have them entered in this spreadsheet, but otherwise they need to go over to Sheet B and enter it in.
To make it easier for them (so they don't have to check every time, or go back and enter info later after getting an error generating the report), I have used conditional formatting. The way it works is, column Z is set up as a helper column, and uses a "COUNTIF" function to check if the client ID in Sheet A, Column A is found in Sheet B, Column C. Sheet A Column Z returns 0 or 1 (or, theoretically, more than one if we had duplicates), and then Sheet A column A has conditional formatting based on Column Z's value-- if the client is already in, the cell for client ID turns green after they type it; if not, it turns red.
It works great! However, I am adding scripts to these sheets, and looping through them. This helper column is filled from Z1 to Z1000, which means I can't use sheet.maxRow() to get the last row.
I see plenty of workarounds on the script side, but I was wondering if anyone has a clever way to input a value into the helper column Z ONLY IF the corresponding cell (same row) in column A has a value using spreadsheet formulas.
I suspect that an array formula with a filter might do it, but I have little experience with either and can't get anything to work out.
Thanks for your help!
You can use this expression with INDEX, MAX and ROW to make an ARRAYFORMULA only expandable until the last cell with value in column:
A2:INDEX(A2:A,MAX(ROW(A2:A)*(A2:A<>"")))
It will go from A2 to the maximum number of row in A in which A is different than null (that's why both conditions are multiplied).
Then you can set a formula like this in Z2 (check the ranges in case something is not right from reading your text, and delete all other formulas in Z too in case you weren't using an arrayformula already):
=BYROW(A2:INDEX(A2:A,MAX(ROW(A2:A)*(A2:A<>""))),LAMBDA(each,IF(each="","",COUNTIF('Sheet B'!C:C,each))))

Apply Arrayformula to formula that shows the last cell of a row (Google Sheet)

I go to the community to find out if there is a solution to my problem which I detail below, I have a data matrix which grows from cell to cell along rows, there are rows that have more data than others and through the formula that I will leave at the end I can obtain the last 3 values of each row up to that point the formulas fulfill their function but when I try to add the Arrayformula I cannot make the formulas work so that they are completed automatically, I would appreciate if you could help me with this problem.
Google Sheet
Here is a possible solution, assuming there are no blank cells between the non-blank cells:
=ArrayFormula(vlookup(
row(C2:C11),
{row(C2:C11),C2:I11},
mod(sequence(rows(C2:C11),3,0),3)+mmult(if(C2:I11<>"",1,0),sequence(COLUMNS(C2:I11),1,1,0))-1,
0))

Setting array formula until last column in Google Sheets

I have a formula as follows in google sheets:
=ARRAYFORMULA(IF(LEN(F2:F),IFERROR(SPLIT(REPT("PAID ",F2:F)&REPT("- ",(24-F2:F))," ")),))
This formula will show paid according to number of paid in the cell and show "-" to the cells in the rest column. For now, this formula is only applicable for columns. I dont want like that, I want this formula to be used until the last column because the number of columns will be increased every year. I dont know whether this should be done in Google App Script or what. Anything should be fine to solve my problems. I have attached some images to explain myself clearly. Thanks in advance.
https://docs.google.com/spreadsheets/d/1bM8l6JefFsPrlJnTWf56wOhnuSjdIwg3hMbY1tN1Zp8/edit#gid=1775459006 - Link to google sheets
I will use the sheet "JALAN SANGGUL 4" as an example. Then you will need to apply to all of the other sheets that have the same structure.
Replace your current G1 formula with this:
=TRANSPOSE(FILTER(Configuration!P2:P,Configuration!P2:P<>""))
Replace your current G2 formula with this:
=ARRAYFORMULA(IF(LEN(F2:F),IFERROR(SPLIT(REPT("PAID ",F2:F)&REPT("- ",(COUNTA(FILTER(G1:1,G1:1<>""))-F2:F))," ",1,1)),))
The added FILTER in each constrains things to only areas where data exists. By counting where only data exists instead of using a set "24" in the second REPT clause, you'll always get dashes going only as far as there are months in Row 1.

How to crossmatch data of a column with multiple column and take action if it matched?

Here I have two sheets in google spreadsheet.
Please check the screenshot
I would like to automatically search all the single data of column A of Sheet 2 in Column A and C of Sheet 1 and if it matched it would make the checkboxes ticked on column B and D of sheet 1 and if its not matched it would leave it as it was. I have attached that screenshot which is the result I expect. Is there any functions or script to do this?
I'm not familiar with such staffs. A help would be greatly appreciated.
Thanks
you do not need to write a script for this - an array formula can do it all
to the formula start working - you need to clear out everything from the range B1:B7 . then paste the formula =ArrayFormula(IFNA(VLOOKUP(A1:A7,Sheet2!$A:$A,1,false),)=A1:A7) into cell B1, then select range B1:B7 and paste checkboxes through the menu Insert - Checkbox
the formula for the range D1:D7 is inserted in the same way
=ArrayFormula(IFNA(VLOOKUP(C1:C7,Sheet2!$A:$A,1,false),)=C1:C7)
after some thought, came to the conclusion that the formulas could be much simpler
=ArrayFormula(COUNTIF(Sheet2!$A:$A,A1:A7)>0) for cell B1
=ArrayFormula(COUNTIF(Sheet2!$A:$A,C1:C7)>0) for cell D1