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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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