Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi Everyone,
I have a table below and I want to create a new column called category with only two items, fruit & other. How to do this with DAX?
| ID | Name | CATEGORY | 
| 1 | APPLE | fruit | 
| 2 | PEACH | fruit | 
| 3 | ORANGE | fruit | 
| 4 | ORANGE | fruit | 
| 5 | PEACH | fruit | 
| 6 | PEACH | fruit | 
| 7 | PEACH | fruit | 
| 8 | APPLE | fruit | 
| 9 | TABLE | other | 
| 10 | PEN | other | 
| 11 | GRAPE | fruit | 
| 12 | GRAPE | fruit | 
| 13 | TABLE | other | 
| 14 | PEN | other | 
| 15 | PEN | other | 
| 16 | APPLE | fruit | 
| 17 | ORANGE | fruit | 
| 18 | PEN | other | 
| 19 | GRAPE | fruit | 
Thanks,
Larry
Solved! Go to Solution.
Hi,
Here is an example:
I hope this helps to solve your issue and if it does consider accepting this as a solution and giving the post a thumbs up!
Proud to be a Super User!
Hi @ValtteriN
May be one more question. I have a similar table below and I also want to create a new column called region. Is there an easy way to do this using DAX?
I tried to duplicate a column in Query editor and use replace values command. But it doesn't support for using of wild cards like " * ". If I have many values then I need to do it one by one. For example how to change all location name with a suffix " Asia " to " APAC " in new column?
| Location | Region (New Column) | 
| America/Mexico | AMERICA | 
| America/New york | AMERICA | 
| Asia/Calcutta | APAC | 
| Asia/Shanghai | APAC | 
| Asia/Tokyo | APAC | 
| Euro/Italy | EU | 
| Europe/London | EU | 
| Europe/Paris | EU | 
| US/Eastern | AMERICA | 
Thanks,
Larry
You probably want a switch for something like this. For example,
Region =
VAR Loc = Table1[Location]
RETURN
    SWITCH (
        TRUE (),
        LEFT ( Loc, 7 ) = "America", "AMERICA",
        LEFT ( Loc, 4 ) = "Asia", "APAC",
        LEFT ( Loc, 4 ) = "Euro", "EU",
        LEFT ( Loc, 3 ) = "US/", AMERICA
    )
Hi,
Here is an example:
I hope this helps to solve your issue and if it does consider accepting this as a solution and giving the post a thumbs up!
Proud to be a Super User!
 
					
				
				
			
		
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
 
            | User | Count | 
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | 
| User | Count | 
|---|---|
| 23 | |
| 14 | |
| 11 | |
| 10 | |
| 9 |