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
Anonymous
Not applicable

Change the names of a column for different names

Hi!

 

I have a column that contains the name of different departments. There are two names though that I would like to be shown with a different name and to change them in the database (origin) it might be more difficult.

Is it possible with a Dax function or an "if" or something to create a new column that shows the name of the departments, with a different new name for three of them:

 

For eample:

 

one column has:                              New column:

 

Finance                                            Finance 2020

Controlling                                      Controlling

IT                                                     Information Technology

Legal                                               Legal international

Marketing                                       Marketing

HR                                                  HR

Product                                           Product

International                                   International

 

Is that possible? Which function should I use?

 

Thanks so much,

JFB

 

 

2 ACCEPTED SOLUTIONS

Not sure without the error code but can be the use of dot comma instead of comma try this:

 

Department Name =
SWITCH (
    [Department],
    " Resolve (italy)", " Italy-Resolve ",
    " Claims (EN)", " UK-Claims (EN)",
    " Customer Relations (EN)", " UK-Customer Relations (EN)",
    [Department]
)

 

If it does not work can you share the error code please.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Anonymous
Not applicable

Now it worked. I had to remove the space after the "

 

🙂

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Now it worked. I had to remove the space after the "

 

🙂

Anonymous
Not applicable

Well it actually did not 😞 hehe. It copied the column exactly as it was, it did not make the changes 😞

MFelix
Super User
Super User

Hi @Anonymous ,

 

You can create that in DAX or M Language.

 

In the query editor add the following code:

if [Column1] = "Finance" then "Finance 2020" else
  if [Column1]= "IT" then "Information Techology"
else if [Column1] = "Legal" then "Legal International"
else [Column1]

 

In dax add the following:

Column = SWITCH( [Column1] ;"Finance";  "Finance 2020";
 "IT" ; "Information Techology";
"Legal"; "Legal International";
[Column1])

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Hi,

it gives me error

Department Name = SWITCH( [Department] ;" Resolve (italy)"; " Italy-Resolve "; " Claims (EN)" ; " UK-Claims (EN)"; " Customer Relations (EN)"; " UK-Customer Relations (EN)"; [Department])

what is wrong there?

Thx

Not sure without the error code but can be the use of dot comma instead of comma try this:

 

Department Name =
SWITCH (
    [Department],
    " Resolve (italy)", " Italy-Resolve ",
    " Claims (EN)", " UK-Claims (EN)",
    " Customer Relations (EN)", " UK-Customer Relations (EN)",
    [Department]
)

 

If it does not work can you share the error code please.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.