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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
InsightSeeker
Helper III
Helper III

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.

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

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!!





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

Proud to be a Super User!





View solution in original post

1 REPLY 1
rajendraongole1
Super User
Super User

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!!





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

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.