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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
bikelley
Helper IV
Helper IV

How to add if statement column values and give column name in else?

Hello, 


I am trying to change some names in my column, but I am not sure how to give column names as default or on else. Can anybody please tell me.  Please see below image, 

 

The isseu is I am not sure how to reffer colunm name in If stament. 

Cap.png

 

Thank you so much

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@bikelley , Syntax is wrong , In dax it like

if([_rep>3] ,3,_rep) //if(<condition>, <then> ,<else>)

 

or is ||

and is &&

 

refer: https://docs.microsoft.com/en-us/dax/if-function-dax

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

v-luwang-msft
Community Support
Community Support

Hi @bikelley 

You cold try  the following measure:

new accountname =
IF (
    'Account Name'[Ac+A1:A19count Name-Hierarchy level 2] = "Ch"
        || 'Account Name'[Ac+A1:A19count Name-Hierarchy level 2] = "Chi"
        || 'Account Name'[Ac+A1:A19count Name-Hierarchy level 2] = "Chic",
    "Chico",
    'Account Name'[Ac+A1:A19count Name-Hierarchy level 2]
)

final you will get like below:

v-luwang-msft_0-1614061647585.png

 

DAX IF:https://docs.microsoft.com/en-us/dax/if-function-dax 

or in dax:||

and in dax:&&

 

 if i answer your question,pls  Mark my post as a solution,thanks!

 

Best Regard

Lucien Wang

View solution in original post

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @bikelley 

You cold try  the following measure:

new accountname =
IF (
    'Account Name'[Ac+A1:A19count Name-Hierarchy level 2] = "Ch"
        || 'Account Name'[Ac+A1:A19count Name-Hierarchy level 2] = "Chi"
        || 'Account Name'[Ac+A1:A19count Name-Hierarchy level 2] = "Chic",
    "Chico",
    'Account Name'[Ac+A1:A19count Name-Hierarchy level 2]
)

final you will get like below:

v-luwang-msft_0-1614061647585.png

 

DAX IF:https://docs.microsoft.com/en-us/dax/if-function-dax 

or in dax:||

and in dax:&&

 

 if i answer your question,pls  Mark my post as a solution,thanks!

 

Best Regard

Lucien Wang

@v-luwang-msft  Thank you so much this works well for me too. Again, thanks for the help. 

amitchandak
Super User
Super User

@bikelley , Syntax is wrong , In dax it like

if([_rep>3] ,3,_rep) //if(<condition>, <then> ,<else>)

 

or is ||

and is &&

 

refer: https://docs.microsoft.com/en-us/dax/if-function-dax

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandakThank you so much this makes sense. I appreciate your time. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.