UNIQUE function does not filter values - google-sheets

=arrayformula(UNIQUE(
{
IFERROR(FILTER('New Bets'!A3:H,'New Bets'!I3:I<>""),{"","","","","","","",""})
;
IFERROR(FILTER(Alertas!A2:H101,Alertas!I2:I101<>""),{"","","","","","","",""})
}))
=UNIQUE(A3:H)
When I use Unique separately from the rest of the formula, it correctly returns only one row with data, without duplicates. But when using inside the formula, it returns two equal values.
I wonder what I'm doing wrong.
Link to Spreadsheet:
https://docs.google.com/spreadsheets/d/1sv1B1mYrhpzS-ZtCLfLkVPtbffWq231woEX_qOxiAXA/edit?usp=sharing

try:
=ARRAYFORMULA(UNIQUE(TRIM(
{IFERROR(FILTER('New Bets'!A3:H,'New Bets'!I3:I<>""),{"","","","","","","",""});
IFERROR(FILTER(Alertas!A2:H101,Alertas!I2:I101<>""),{"","","","","","","",""})})))

Related

Refining a Query formula with two 'where' conditions

I need to write a Query formula to pull through unique values from another sheet, excluding rows that contain certain keywords and also excluding any empty rows.
I've written this formula:
=UNIQUE(QUERY('Sheet Name'!A1:AZ,"Select A where A is not null and where not A contains 'STRING'",1))
Unfortunately this gives a VALUE error. It works with either of the 'where' clauses but not with both.
What am I missing?
You don't need to add the seconde 'Where', it just implies that you continue to add conditions into that statement:
=UNIQUE(QUERY('Sheet Name'!A1:AZ,"Select A where A is not null and not A contains 'STRING'",1))

Google Sheets Filter Function based on condition

I am trying to create a filter function based on a condition, but when the condition is false I receive the error saying that the array returns empty rows.. Anything I can do?
={IF($C5,SORT(FILTER($AE3:$BL,$AF$3:$AF=$D5),1,TRUE),"");
IF($C6,SORT(FILTER($AE3:$BL,$AF$3:$AF=$D6),1,TRUE),"");
IF($C7,SORT(FILTER($AE3:$BL,$AF$3:$AF=$D7),1,TRUE),"");
IF($C8,SORT(FILTER($AE3:$BL,$AF$3:$AF=$D8),1,TRUE),"");
IF($C9,SORT(FILTER($AE3:$BL,$AF$3:$AF=$D),1,TRUE),"");
IF($C10,SORT(FILTER($AE3:$BL,$AF$3:$AF=$D10),1,TRUE),"")
}
You might try this formula:
=QUERY(AE3:BL,"where AF matches '"&JOIN("|",FILTER(D5:D10,C5:C10))&"' order by AF,AE",0)
or this if you prefer, but just didn't know how to ask:
=QUERY(AE3:BL,"where AF matches '"&JOIN("|",FILTER(D5:D10,C5:C10))&"' order by AE",0)

Exact match in dget function with an array as the criteria

Example Sheet I'm trying to get an exact match with an array in the criteria section of dget. Maybe there is another way to work around this, but I'm trying to give it a dynamic component in the array.
=dget('Micro Data'!$A$1:J,"PCR Score",{"Micro Type","Stage Type","Tank","ID#";"PCR PAL","Bright",F2,H2})
Sometimes all criteria matches multiple data points except the "Tank". However the tanks won't exactly match. Ex. All the data is the same in two data sets, except the tanks are CT1 and CT18. This then comes up with the #NUM! error. I'm trying to find if there is a way to get an exact match in the array data while still allowing it to reference the cell?
I know there is the option of making it "=XXX" making it a txt string, but this would take away the dynamic function. I would also loose the auto updating aspect when more data is added.
Thanks
Ryan, see my solution using a query, in Retain Log-GK, cell F2. I think it is just as dynamic as the dget, but perhaps not. It will need some error wrapping to avoid errors if no result found.
Formula is basically:
=query('Criteria Source'!A2:J5,
"select J where B = '"&D9&"' and C = '"&D10&"' and E = '"&D11&"' and D ='"& D2 & "' ",0)
I made all of the criteria dynamic, though obviously you can do it whatever way suits you best...
Let me know of any questions. I'll check back later...

How do i remove rows based on comma-separated list of values in a Power BI parameter in Power Query?

I have a list of data with a title column (among many other columns) and I have a Power BI parameter that has, for example, a value of "a,b,c". What I want to do is loop through the parameter's values and remove any rows that begin with those characters.
For example:
Title
a
b
c
d
Should become
Title
d
This comma separated list could have one value or it could have twenty. I know that I can turn the parameter into a list by using
parameterList = Text.Split(<parameter-name>,",")
but then I am unsure how to continue to use that to filter on. For one value I would just use
#"Filtered Rows" = Table.SelectRows(#"Table", each Text.StartsWith([key], <value-to-filter-on>))
but that only allows one value.
EDIT: I may have worded my original question poorly. The comma separated values in the parameterList can be any number of characters (e.g.: a,abcd,foo,bar) and I want to see if the value in [key] starts with that string of characters.
Try using List.Contains to check whether the starting character is in the parameter list.
each List.Contains(parameterList, Text.Start([key], 1)
Edit: Since you've changed the requirement, try this:
Table.SelectRows(
#"Table",
(C) => not List.AnyTrue(
List.Transform(
parameterList,
each Text.StartsWith(C[key], _)
)
)
)
For each row, this transforms the parameterList into a list of true/false values by checking if the current key starts with each text string in the list. If any are true, then List.AnyTrue returns true and we choose not to select that row.
Since you want to filter out all the values from the parameter, you can use something like:
= Table.SelectRows(#"Changed Type", each List.Contains(Parameter1,Text.Start([Title],1))=false)
Another way to do this would be to create a custom column in the table, which has the first character of title:
= Table.AddColumn(#"Changed Type", "FirstChar", each Text.Start([Title],1))
and then use this field in the filter step:
= Table.SelectRows(#"Added Custom", each List.Contains(Parameter1,[FirstChar])=false)
I tested this with a small sample set and it seems to be running fine. You can test both and see if it helps with the performance. If you are still facing performance issues, it would probably be easier if you can share the pbix file.
This seems to work fairly well:
= List.Select(Source[Title], each Text.Contains(Parameter1,Text.Start(_,1))=false)
Replace Source with the name of your table and Parameter1 with the name of your Parameter.

comparing Decimal(9,3) column value in Linq

I have a column pointsAwarded decimal(9,3) and I have the following LInq
db.TableName.Select(x=>x.pointsAwarded >0)
The fact is that it is not filtering the data and returning me the whole result set.
How to compare it?
I tried with x.pointsAwarded.value>0 and x.pointsAwarded.value>0.000 and
x.pointsAwarded > (Decimal?)0
but with no luck.
Pls help
Try using a Where instead of a Select
db.TableName.Where(x=>x.pointsAwarded > 0)
UPDATE:
This answer has been given more credit than it previously deserved, so I will elaburete a little
The Where statement acts as the filter. It determins whitch elements the returned list should contain.
The Select statement is the projection of the elements. Given a list of elements, how would you like them presented.

Resources