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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

conditional relationship

Hi, I am importing tables from SQL Server into Power Bi. Two tables, named TB and AP, have a 1-to-many relationship with a condition, ie:

TB.VLAS=AP.TPGE AND
CDA = '025' AND
NMF = 'AP' and NMC = 'TPGE'

What should I do to create this conditional relationship between the two tables? Can you please explain what to do? I am new to Power Bi, thank you!

4 REPLIES 4
HotChilli
Community Champion
Community Champion

General advice: Most tables/relationships in SQL Server are designed as a balance between input/update/selection.  They are supposed to be normalised (supposed to be). Powerbi is a reporting system which is designed for reading of data.  Use a star schema to optimise this and you transform the data in Power Query.

--

So the answer to your question may go away because you've changed the design. It is,generally, a mistake to import the tables from SQL Server as they are and try to recreate the relationships. In powerbi, you can't have multiple key relationships anyway.

fahadqadir3
Super User
Super User

@Anonymous  Add calculated columns in both TB and AP tables to capture the condition for the relationship.

In the TB table, create a calculated column:

ConditionalKey_TB = IF(TB[CDA] = "025" && TB[NMF] = "AP" && TB[NMC] = "TPGE", TB[VLAS], BLANK())

 In "AP" Table 

ConditionalKey_AP = IF(AP[CDA] = "025" && AP[NMF] = "AP" && AP[NMC] = "TPGE", AP[TPGE], BLANK())

Once you have created these calculated columns, you can establish a relationship between the TB and AP tables based on these new columns.

Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.

Anonymous
Not applicable

i don't have a column in TB named CDA. I have this column only on AP and column NMC is only on TB table, not in AP table. So how i can edit your query? thank you

Anonymous
Not applicable

please, someone can help me?

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.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.