Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rambabukm
New Member

find the Text values which contains in columns .

hi, i want to add a values based on the column witch contains values. Ca you please check the bellow quer, using this need to add in powerbi.

Ex:

IF CONTAINS([Name], 'AA') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AZ') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AW') THEN 'APAC'
ELSEIF CONTAINS([Name], 'AR') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AY') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AI') THEN 'AMER'
ELSEIF CONTAINS([Name], 'AQ') THEN 'APAC' END

 

2 ACCEPTED SOLUTIONS
erik_tarnvik
Solution Specialist
Solution Specialist

Instead of creating a formula for this purpose, I would suggest that you create a table with the country-region mapping and bring that table into your model and define a relationship between your fact table and the mapping (dimension) table. This would be much easier, it will be a very long if statement otherwise.

View solution in original post

Eric_Zhang
Employee
Employee


@rambabukm wrote:

hi, i want to add a values based on the column witch contains values. Ca you please check the bellow quer, using this need to add in powerbi.

Ex:

IF CONTAINS([Name], 'AA') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AZ') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AW') THEN 'APAC'
ELSEIF CONTAINS([Name], 'AR') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AY') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AI') THEN 'AMER'
ELSEIF CONTAINS([Name], 'AQ') THEN 'APAC' END

 


@rambabukm

What values are in the column Name in your case? If they're simply "AA","AZ" and etc, you can follow @erik_tarnvik suggestion to create mapping table and create proper relationship.

 

Otherwise, you could try below DAX formula.

Column = 
SWITCH(TRUE(),SEARCH("AA",'Table'[Name],1,0)>0||
			  SEARCH("AZ",'Table'[Name],1,0)>0||
			  SEARCH("AR",'Table'[Name],1,0)>0||
			  SEARCH("AY",'Table'[Name],1,0)>0,
			  "EMEA",
			  SEARCH("AW",'Table'[Name],1,0)>0||
			  SEARCH("AQ",'Table'[Name],1,0)>0,
			  "APAC",
			  SEARCH("AI",'Table'[Name],1,0)>0,
			  "AMER")

View solution in original post

2 REPLIES 2
Eric_Zhang
Employee
Employee


@rambabukm wrote:

hi, i want to add a values based on the column witch contains values. Ca you please check the bellow quer, using this need to add in powerbi.

Ex:

IF CONTAINS([Name], 'AA') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AZ') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AW') THEN 'APAC'
ELSEIF CONTAINS([Name], 'AR') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AY') THEN 'EMEA'
ELSEIF CONTAINS([Name], 'AI') THEN 'AMER'
ELSEIF CONTAINS([Name], 'AQ') THEN 'APAC' END

 


@rambabukm

What values are in the column Name in your case? If they're simply "AA","AZ" and etc, you can follow @erik_tarnvik suggestion to create mapping table and create proper relationship.

 

Otherwise, you could try below DAX formula.

Column = 
SWITCH(TRUE(),SEARCH("AA",'Table'[Name],1,0)>0||
			  SEARCH("AZ",'Table'[Name],1,0)>0||
			  SEARCH("AR",'Table'[Name],1,0)>0||
			  SEARCH("AY",'Table'[Name],1,0)>0,
			  "EMEA",
			  SEARCH("AW",'Table'[Name],1,0)>0||
			  SEARCH("AQ",'Table'[Name],1,0)>0,
			  "APAC",
			  SEARCH("AI",'Table'[Name],1,0)>0,
			  "AMER")
erik_tarnvik
Solution Specialist
Solution Specialist

Instead of creating a formula for this purpose, I would suggest that you create a table with the country-region mapping and bring that table into your model and define a relationship between your fact table and the mapping (dimension) table. This would be much easier, it will be a very long if statement otherwise.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.