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.
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
Solved! Go to Solution.
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.
@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
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")
@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
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")
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
98 | |
77 | |
66 | |
53 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |