I have a string column, which contains a list of string values separated by commas.
I converted the column into a List by using M syntax
Now I would like to write a DAX query that would compare the Names column with a criteria table and return a row if there are intersections. Something like this:
FILTER(Users, INTERSECTSWITH(Users[Names], {{"Joe", "Meg"}}))
which should return rows 1 and 3.
INTERSECTSWITH does not exist in DAX, but is there an equivalent technique to compare one list to another?
Thanks!
Related
Is there a function in Power BI that can check whether a list of specified values (numbers) exists in a column?
For example, in the image below, I have a column with some values and another one with 0 and 1s. You can see that some values are marked with 1 and some with 0. In order to do this, I used IF function, but this is just too cumbersome.
I am looking for a formula that can check if the values from a list like {XXXX, XXXX, XXXX, etc} exist in a column and that can easily be edited when I need to add other values.
Thank you and have a good day!
Best,
Denis
You can do that by adding a custom column for example. If we assume your table is named Table and first column is named Value, then add a custom column like this:
Where the list contains all the values of interest. This will give you a boolean column Flag:
If you want an integer column with 0 and 1 values, then change the column to something like this:
= if (List.Contains({"5006", "4905"}, [Value])) then 1 else 0
Having some trouble with a very simple problem. I want to create 1 list in a column based on data from two different columns, I only want each item to appear once in the list column.
So to create the list based on data from one column, I used this formula but I don't know how to do it from 2 (and the number of occurrences/count isn't needed).
=ArrayFormula(QUERY(J2:J&{"",""},"select Col1, count(Col2) where Col1 != '' group by Col1 label count(Col2) 'Number of occurrences'",-1))
https://docs.google.com/spreadsheets/d/1loPw3eUALLKx3NzXrxhDszqD2_B7G3cyH1EhnYg4tFg/edit?ts=5cf63f94#gid=0
Maybe something like:
=sort(UNIQUE({A1:A10;B1:B12}))
If your locale uses , as separator, the lists are in A1:A10 and B1:B12 and you want the result sorted.
I have some table data in which I'd like to sum all the values in a specific column of all rows where column A contains string A and/or column B contains string B. How can I achieve this?
This works for one criterium:
=SUM(FILTER(G:G,REGEXMATCH(F:F,"stringA")))
I tried this, but it didn't work:
=SUM(FILTER(G:G,OR(ISTEXT(REGEXMATCH(F:F,"stringA")),ISTEXT(REGEXMATCH(C:C,"stringB")))))
Please try:
=SUM(FILTER(G:G,REGEXMATCH(F:F,"stringA")+REGEXMATCH(C:C,"stringB")))
+ works for or logic. ISTEXT is not needed because REGEXMATCH gives true or false.
OR does not work because filter is an arrayformula, use + in array formulas.
=SUM(FILTER(G:G,REGEXMATCH(F:F&C:C,"stringA|stringB")))
OR is denoted by |
EDIT Added &C:C to denote different Columns
In my for loop I would like to divide a column by another. The second column's name is dependent upon the first. Example data frame columns look like this:
column1, column1_mean, column2, column2_mean
I would like to iteratively divide each column by its corresponding mean column ( column1 / column1_mean; column2/column2_mean ).
Thanks for your help.
For a given list of column names cols = ['column1', 'column2', ... ], you can use .div() to divide a list of columns by another list of columns, and use string formatting to make the second list of columns based on the first:
df[cols].div(df[['{0}_mean'.format(col) for col in cols]])
But a simpler way would be to dispense with making the mean columns altogether:
df[cols].div(df[cols].mean())
In one spreadsheet I have 3 columns with a first and last name of a person combined. In the 2nd spreadsheet, I have column a = first name and column b = last name.
I want to know which names in spreadsheet one cannot be found in spreadsheet two. I also need to verify the data to make sure that the formula was accurate on finding the correct lookup.
Do I have to combine my columns in spreadsheet 2 to make the first and last name in the same column to make this work?
Which formula would you use for either scenario?
Use this:
=ISNA(MATCH($A1&" "&$B1,Sheet2!$A:$A,FALSE)))
Where (in order):
A1 is the first name column in Sheet1
B1 is the last name column in Sheet1
Sheet2 is the sheet that has the data stored as names separately
$A:$A is the rows that have the two names together
FALSE is because it's an exact match
This will return FALSE if the element does not exist, and TRUE if it does
You can also use:
=VLOOKUP($A1&" "&$B1,Sheet2!$A:$D,3,FALSE)
If you want to retrieve data for a match.
Finally, if you need to do your lookups the other way, take a look at this thread for some ideas on how to split the string into two pieces.