DAX 'CONTAINSX' type formula

dpotta

New Member
Joined
Aug 16, 2011
Messages
29
Hi

I have two unrelated tables. postcodes is a complete list of UK postcodes and sf is a table of opportunity names. I have been using the formula below to search for a postcode within the column [opportunity name] in the sf table and return Yes/No.


Postcode = IF(
SUMX(postcodes,
FIND(
UPPER(postcodes[Postcode]),
UPPER(sf[Opportunity Name])
,,0
)
) > 0,
"Yes",
"Probably not"

What I would like to do is use a variation of the formula to return the actual postcode rather than "yes". I have tried using LOOKUPVALUE in there, but I still cannot work out how to do this with two unconnected tables. This is an example of the sf[opportunity name] column. The formula returns "Yes" in the two bold rows.

EMEA ? A company name ? Flat 12, 100 A road, London W1J 9NH ? Product
EMEA ? A company name ? 35-37 & 39 Molyneux Road, London GU& 3NJ? Other Products

EMEA - A company name - 29 Meanwhile Gardens, London - Q1 2016 Valuation - Different Products
EMEA - UK - Habro - Aberdeen - Jesmond Drive Part 22

Can anyone help?

Many thanks in advance

Dave
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Finding a UK Postcode in a text string with DAX

Hi

I have two unrelated tables. postcodes is a complete list of UK postcodes and sf is a table of opportunity names. I have been using the formula below to search for a postcode within the column [opportunity name] in the sf table and return Yes/No.


Postcode = IF(
SUMX(postcodes,
FIND(
UPPER(postcodes[Postcode]),
UPPER(sf[Opportunity Name])
,,0
)
) > 0,
"Yes",
"Probably not"

What I would like to do is use a variation of the formula to return the actual postcode rather than "yes". I have tried using LOOKUPVALUE in there, but I still cannot work out how to do this with two unconnected tables. This is an example of the sf[opportunity name] column. The formula returns "Yes" in the two bold rows.

EMEA ? A company name ? Flat 12, 100 A road, London W1J 9NH ? Product
EMEA ? A company name ? 35-37 & 39 Molyneux Road, London GU& 3NJ? Other Products

EMEA - A company name - 29 Meanwhile Gardens, London - Q1 2016 Valuation - Different Products
EMEA - UK - Habro - Aberdeen - Jesmond Drive Part 22

Can anyone help?

Many thanks in advance

Dave


Resolved! This works with the following formula:

=FIRSTNONBLANK(FILTER(
VALUES(Postcodes[postcode]),
SEARCH(
postcodes[postcode],
sf[Opportunity Name],
1,
0
)
)
,1
)
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top