The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello
I would like a column that shows whether or not a column in Table2 contains values that are in Table1.
Table1 | |
Value | New Column |
A | TRUE |
B | FALSE |
C | TRUE |
D | FALSE |
E | TRUE |
Table2 |
Value |
A |
C |
E |
Any Ideas?
Thanks!
Solved! Go to Solution.
Hi @bullius. If table 2 contains only unique values, you could relate the two tables on the Value column, and then use this formula for your New Column:
New Column = NOT(ISBLANK(RELATED(Table2[Value])))
You can also use the formula below, which will work with or without the relationship:
New Column = CALCULATE(COUNTROWS(Table2), FILTER(Table2, Table2[Value]=Table1[Value])) > 0
See this post for more information about how each method works.
I know KGrice's formula worked but it does seem a tad clunky... you could consider this as a slightly cleaner alternative (since the CONTAINS function exists exactly for this purpose):
Column = CONTAINS(Table2, Table2[Value], Table1[Value])
Hi @bullius. If table 2 contains only unique values, you could relate the two tables on the Value column, and then use this formula for your New Column:
New Column = NOT(ISBLANK(RELATED(Table2[Value])))
You can also use the formula below, which will work with or without the relationship:
New Column = CALCULATE(COUNTROWS(Table2), FILTER(Table2, Table2[Value]=Table1[Value])) > 0
See this post for more information about how each method works.
Although I have a relationship the second option is not working.
Thanks for the reply.
Table2 does not contain unique values...
Hi @bullius. The unique values piece only matters for creating a relationship. The second option I listed does not require unique values in either table. Were you able to get that one working?
Yes! The second one does the job. Thanks!
I know KGrice's formula worked but it does seem a tad clunky... you could consider this as a slightly cleaner alternative (since the CONTAINS function exists exactly for this purpose):
Column = CONTAINS(Table2, Table2[Value], Table1[Value])
but with this method, there has to be a relationship established between tables, right ?
Thanks, @jahida. I hadn't come across the CONTAINS function yet. I'll start using that instead.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
80 | |
78 | |
47 | |
39 |
User | Count |
---|---|
148 | |
115 | |
65 | |
64 | |
53 |