Forum Discussion

InsightSeeker's avatar
InsightSeeker
Helper III
2 years ago
Solved

Assistance Needed for Creating a New Column

Hello,

 

I need help to create a new column based on the following conditions:

 

- If the settle name is equal to "Card" or "OCCF", and
- The code is equal to "000100160", and
- The number length is 11, and
- The first 4 digits of the number are "4398", and
- The last 4 digits of the number are "1614", and
- The code is not blank,

 

then return "valid"; otherwise, return "error".

 

The data is in Table1.

 

settle_nameCodeNumberCode
Card0001001604398XX7614162932
Card0001001604398XXX1614101256
OCCF0001001604398XXX16145105352
OCCF00010016014398XXX1614105938
OCCF0001001604398XXX1614106780
Card0001001604398XXX1614 
Card0001001604398XXX1614111260
Card0001001604398XXX1614

111496

 

Result

 

settle_nameCodeNumberCodeStatus
Card0001001604398XX7614162932Error
Card0001001604398XXX1614101256Valid
OCCF0001001604398XXX16145105352Error
OCCF00010016014398XXX1614105938Error
OCCF0001001604398XXX1614106780Valid
Card0001001604398XXX1614 Error
Card0001001604398XXX1614111260Valid
Cash0001001604398XXX1614111496

Error

 

Thank you for your assistance.

  • Hi InsightSeeker -  Here's how you can create a calculated column based on the given conditions

    NewColumn =
    IF (
    OR (
    'YourTableName'[settle name] = "Card",
    'YourTableName'[settle name] = "OCCF"
    ) &&
    'YourTableName'[code] = "000100160" &&
    LEN('YourTableName'[number]) = 11 &&
    LEFT('YourTableName'[number], 4) = "4398" &&
    RIGHT('YourTableName'[number], 4) = "1614" &&
    NOT ISBLANK('YourTableName'[code]),
    "valid",
    "error"
    )

    you can replace 'YourTableName' with the actual name of your table, and 'settle name', 'code', and 'number' with the actual column names in your dataset.

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!

1 Reply

  • Hi InsightSeeker -  Here's how you can create a calculated column based on the given conditions

    NewColumn =
    IF (
    OR (
    'YourTableName'[settle name] = "Card",
    'YourTableName'[settle name] = "OCCF"
    ) &&
    'YourTableName'[code] = "000100160" &&
    LEN('YourTableName'[number]) = 11 &&
    LEFT('YourTableName'[number], 4) = "4398" &&
    RIGHT('YourTableName'[number], 4) = "1614" &&
    NOT ISBLANK('YourTableName'[code]),
    "valid",
    "error"
    )

    you can replace 'YourTableName' with the actual name of your table, and 'settle name', 'code', and 'number' with the actual column names in your dataset.

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!