Reply
csolanky
Regular Visitor
Partially syndicated - Outbound

Custom column help needed

segment1Category
2000Air Transportation
2000Donor Tissue Typing
2000Ground Transportation
2000Hospital & Physician Costs
3000Air Transportation
3000Hospital & Physician Costs
3000Recovery Supplies
3000Serology

 

Need help with this custom column. It seems to work but as soon as I add the "and [segment1]" part, it does not work. segment1 is a text field. I have tried using quotes like "2000". Still doesn't work.

if List.Contains({"Hospital & Physician Costs","Surgeon Fees","Ground Transportation","Air Transportation","Serology","Donor Tissue Typing","Recovery Supplies","Other Organ Expenses"}, [Category]) and [segment1]=2000
then "Direct Organ"
else if List.Contains({"Hospital & Physician Costs","Surgeon Fees","Ground Transportation","Air Transportation","Serology","Donor Tissue Typing","Recovery Supplies","Historical Year Discards","Other Tissue Expenses"}, [Category])
then "Direct Tissue"
else "Other"

1 ACCEPTED SOLUTION

Syndicated - Outbound

@csolanky your code works fine for me I am not getting any errors.

 

Categories is just a step I created to remove redundancy of the same list

= {"Hospital & Physician Costs","Surgeon Fees","Ground Transportation","Air Transportation","Serology","Donor Tissue Typing","Recovery Supplies","Other Organ Expenses"}

 

AntrikshSharma_1-1718896474825.png

 

 

View solution in original post

12 REPLIES 12
dufoq3
Super User
Super User

Syndicated - Outbound

Hi @csolanky, provide sample data in usable format (read note below if you don't know how) and expected result based on sample data please.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Syndicated - Outbound

Added sample data. 

BiAnalyst
Resolver I
Resolver I

Syndicated - Outbound

Hey @csolanky  could you try swicth instead?

 

SWITCH (
TRUE,
List.Contains({"Hospital & Physician Costs","Surgeon Fees","Ground Transportation","Air Transportation","Serology","Donor Tissue Typing","Recovery Supplies","Other Organ Expenses"}, [Category]) && [segment1] = 2000, "Direct Organ",
List.Contains({"Hospital & Physician Costs","Surgeon Fees","Ground Transportation","Air Transportation","Serology","Donor Tissue Typing","Recovery Supplies","Historical Year Discards","Other Tissue Expenses"}, [Category]), "Direct Tissue",
"Other"
)

might do the trick!

Syndicated - Outbound

@BiAnalyst SWITCH isn't a function in M language.

Syndicated - Outbound

@BiAnalyst I get an error that SWITCH not recognized. I belive there is no built-in Switch function in Power Query. I could be wrong though.

AntrikshSharma
Super User
Super User

Syndicated - Outbound

@csolanky What is the error message? Always mention that in your question. Check if the column name "segment1" doesn't have any trailing or leading spaces or any other unwanted characters.

Syndicated - Outbound

@AntrikshSharma No error message. All the values fall in the Other bucket.

Syndicated - Outbound

@csolanky How is there no error message? your question title says custom column error.

Syndicated - Outbound

Wrong choice of words for the title. Truly I needed help with teh custom column. Thanks for heads up!

Syndicated - Outbound

@csolanky your code works fine for me I am not getting any errors.

 

Categories is just a step I created to remove redundancy of the same list

= {"Hospital & Physician Costs","Surgeon Fees","Ground Transportation","Air Transportation","Serology","Donor Tissue Typing","Recovery Supplies","Other Organ Expenses"}

 

AntrikshSharma_1-1718896474825.png

 

 

Syndicated - Outbound

Thanks. Must be something else that is whacky on my end. Thanks for reponse. 

Syndicated - Outbound

@AntrikshSharma Just checked, no trailing or leading spaces.

avatar user

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)