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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
PBI_AMS
Helper I
Helper I

Switch statement with condition?

I'm trying to add a column to a table for reporting in the service. I have two tables: 

Opportunity

Employee

 

The Employee table is connected to the Opportunity table in as many as 4 different places: Leader, Expert, Source, Team Member. Each of these can also be blank.  The "Leader" is the active connection.  I want to add a column that says: 

 

Is there a name in the Source field? If so, pull the name of the Department associated with the Source from the related Employee table. Otherwise leave it null. So I'm not sure how to tell Power Query to refer to the "Source" connection between the Employee and Opportunity tables. 

 

This is producing  null where it should be, but it's giving me an error where I want the "Source" Department: 

 

Table.AddColumn(#"Renamed columns 2", "Business Source", each if [Source] is null then null else RELATED[#"Employee(department)"])
I feel like I'm missing something like a switch statement? 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @PBI_AMS ,

Please try to use the following codes:

Table.AddColumn(#"Renamed columns 2", "Business Source", each if [Source] is null then null else RELATEDTABLE(Employee)[department])

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @PBI_AMS ,

Please try to use the following codes:

Table.AddColumn(#"Renamed columns 2", "Business Source", each if [Source] is null then null else RELATEDTABLE(Employee)[department])

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.