Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Custom column IF ELSE, make ELSE accept original value

I want to create a new column using custom column.

 

newcolumn=

if [fullfillmentObject] = "abc" then "ABC"
else if [fullfillmentObject] = "def" then "DEF"
else if [fullfillmentObject] = "ghi" then "GHI"

else [fullfillmentObject] #HERE IS THE ISSUE

 

where ELSE will take the original value of 'fullfillmentObject'. Currently, I use NULL in ELSE statement..

3 Replies

  • AlB's avatar
    AlB
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

    So what is the issue exactly? You already have what you are describing

    Please mark the question solved when done and consider giving kudos if posts are helpful.

    Contact me privately for support with any larger-scale BI needs

    Cheers 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Please see the below DAX query

     

    Column = SWITCH(TRUE(),
    AND(_Char[Char] = "ABC", _Char[Char] = "DEF"),_Char[Char],UPPER(_Char[Char]))
  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft Employee

    I would use this approach in your new column if you want to do it in query:

     

    =if List.Contains({"abc", "def","ghi"}, [Value]) then Text.Upper([Value]) else [Value]

     

    If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat