Get nth mat-row in cypress - angular-material

I have a mat-table where I need to get the 2nd, 3rd row, etc.
when I do:
cy.get('mat-table').find('mat-row').eq(1)
it will find the first row.
However, when I do:
cy.get('mat-table').find('mat-row').eq(2)
it's not finding the 2nd row.
Any idea?
Thanks

Try this:
cy.get('mat-table mat-row').eq(1)
If it is not helping, can you add the error which you are getting and may be the html layout?
Also according to this, your first statement should be getting second element as indexing starts from 0

Related

Is it possible to give a cell a different value than it displays?

What I mean by this is maybe explained easiest with an example:
I habe a list of items and every item has a name and an ID.
I want to sort that list by ID, with the exception to have item "XYZ" with ID 24 alwas on first place. So I would like to give it's ID-cell the value 0 (for sorting) but it should still show the value 24.
Sounds weird and is probably not possible?
Edit: I want it to look like this:
If the user is sorting (using the filter drop down menu) by ID column, it should be sorted as it's in this picture.
I found a solution for the first ID (Hans): Custom number format for that cell:"0;0;"24". It will show the value 0 as '24'. That doesn't help for Franz tho. Here I want a value between 5 and 7 showed as '??'.
A possible solution would be creating a second ID and sorting the values based on this new ID. Something like this:
If you are sorting through formula in other columns you can use:
=SORT(A2:B,MAP(B2:B,LAMBDA(id,IF(id=24,0,id))),1)
Exclude that first item from sorting then merge again. Try the following formula.
={A1:B2;SORT(A3:B,2,1)}
Built an array youself for sorting with IF(A1:A7=24,0,A1:A7), so that XYZ will have its weight as 0,
place it next to your data as the 3rd column with {},
use QUERY() to sort the data and get rid of the 3rd column.
Formula:
=ArrayFormula(
QUERY({A1:B7,IF(A1:A7=24,0,A1:A7)},
"Select Col1,Col2 Order By Col3 ASC",
1)
)
I found the solution (with a little help):
For only the cells you want to show "Something else" but be handled as the values, edit the Custom number format to:
By this, it will always show what you put in there, no matter what value the cell has.

Sheet Query formula giving the incorrect output

I have a sheet where the query formula used is very simple.
Here is the test sheet
It just have to display the conetents of the second sheet in the first. Unfortunately, at some point the cell values are merged into single cells.
The example below shows till Apple1 to Apple 10 the data is merged in row 1.
I need a reason for this error and please avoid answering like, delete the row 15 of fruits tab sheet to correct.
Any cause for this is really appreciated.
Sheet2
Sheet1
QUERY has several arguments. If you don't include them, they are assumed to be defaults (with the third argument being to try to make the first row into a header). Try this instead:
=query(Fruits!A3:F,"Select *",0)
or you can leave the middle argument blank in your case:
=query(Fruits!A3:F,,0)

Why INDIRECT function returns a 1?

I'm trying to return a count of names from another sheet (it's a list of names in Column A and I want to pull the # of individual names into a cell in another sheet). I have many sheets with varying lists of names. I'm using the COUNTA(INDIRECT function, but I keep getting "1" as the result.
=COUNTA(INDIRECT("'"&A2&"'!A:A))")
Can anyone help?
You're nearly there, just have to move the last quote inside the brackets and remove the extra bracket.
=COUNTA(INDIRECT("'"&A2&"'!A:A"))
to account for errors such as "nothing to count" you will need:
=COUNTA(IFERROR(INDIRECT("'"&A2&"'!A:A")))
and btw that was the reason why you were getting 1 from your formula attempt because COUNTA counted the error.

Exclude empty cells when using SORT() in descending order

Use case
Sort formula against other sheet but exclude empty values after last item. Empty values get sorted at top, creating a whole bunch of blank space, and then data I care about.
=SORT('other sheet'!A1:C36,'other sheet'!D1:D36,FALSE)
A-C is the data I wish to show.
D is the column I wish to sort on.
Problem
The "36" must be manually updated each time I add/remove a row to 'other sheet'.
Possible solution would be:
Get the row number of the last non-empty cell in a column in Google Sheets as [last row].
=SORT('other sheet'!A1:C[last row],'other sheet'!D1:D[last row],FALSE)
What I tried
Lookup("",'other sheet'!A:A)
Result: #N/A
No examples in Help for finding empty cells
Get the last non-empty cell in a column in Google Sheets
Returns value not address. Could find that value in row but not as efficient. Also what if value is found in more than one place?
** Example Speadsheet **
https://docs.google.com/spreadsheets/d/1bqiVe3pBYDJFtrO4EysSKTDq17lzY5r2b8sPV-KnTdI/edit#gid=0
I cannot recreate this in a new spreadsheet. I believe this may be a bug.
If you want to find the last row, you can use the following formula.
=SORT(INDIRECT("'other sheet'!A1:C"&QUERY(TRANSPOSE(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A="")),"select Col1")),INDIRECT("'other sheet'!D1:D"&QUERY(TRANSPOSE(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A="")),"select Col1")),FALSE)
The code in bold is a formula to find the first blank cell in column A in 'other sheet'.
The code in italic return a reference range based on the bolded code.
I hope this help even though it seems to be a very long time since your question.
Edited: I just found out that query can limit rows.
=SORT(INDIRECT("'other sheet'!A1:C"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),INDIRECT("'other sheet'!D1:D"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),FALSE)
Edited: Sorry, I didn't read the question carefully. If you want to remove the first blank cell when sort in descending order, you just have to simply add a QUERY function at front, without query for anything.
=QUERY(SORT(INDIRECT("'other sheet'!A1:C"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),INDIRECT("'other sheet'!D1:D"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),FALSE),"")

Spreadsheets get unique names but ignore blank cells

I would like to use spreadsheets to get all unique names from Column A in a table but in the same time I would like blank cells to be ignored. So far I've got this formula that returns all of the unique names from column A but I don't know how to go about ignoring blank cells and not repeating values that have once been added previously.
Here is how my document looks so far. As you can see everything stops after Megan because there is a blank cell.
=IFERROR(INDEX($A$2:$A$90, MATCH(0, COUNTIF($I$10:I10, $A$2:$A$90), 0)), "")
Searched long and wide but came up with nothing, if anyone has any idea how one could do that I would really appreciate it. Thanks!
=unique(A2:A) should work
=unique(filter(A2:A,A2:A<>"")) to also ignore blanks
Yet another hack
=SORT(UNIQUE(A2:A))
Technically, this does not remove the blank result. But nonetheless puts it at the end of the list. You'll also benefit from the sort if you need it. 😁
You can use query:
=unique(query(A2:A,"select A where A<>''"))
You can use this code:
=IFERROR(INDEX($A$2:$A$90, MATCH(0, INDEX(COUNTIF($I$10:I10, $A$2:$A$90)+($A$2:$A$90=""), ), 0)), "")
should work

Resources