The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.
User | Count |
---|---|
83 | |
83 | |
37 | |
34 | |
32 |
User | Count |
---|---|
92 | |
79 | |
62 | |
53 | |
51 |