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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Joining tables with conditional statement using min and max

Hi, 

 

I have two tables. I would like to bring the column [Category] from table2, into table1. For my relationship I.D., I believe that I should use table1[Number] joined with a conditional statement for table2[Start Number] & table2[End Number]. 

 

I have provided an example below with table1 & table2. Table1[Goal Column] is what I am trying to do. As you can see, it's a one-to-many relationship, from table2 to table1, exept table2 must use two columns for the relationship I.D.: [Start Number] and [End Number]. The table2[Start number] is the minimum value and table2[End Number] is the maximum number. Any table1[Number] value between these values should have the appropriate table2[Category]. 

 

I appreciate your willingness to help me out! 

 

Table 1  
WellNumberGoal Column
justin1000Happy
justin1001Happy
justin1002Happy
justin1003Happy
justin1004Happy
justin1005Sad
justin1006Sad
justin1007Sad
brett5000Happy
brett5001Happy
brett5002Sad
brett5003Sad
brett5004Sad
brett5005Sad
brett5006Sad

 

 

Table 2   
WellStart NumberEnd NumberCategory
justin10001005Happy
justin10051007Sad
brett50005002Happy
brett50025006Sad

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the link down below.

It is for creating a new column.

 

Picture1.png

 

Goal Column CC =
VAR currentwell = Table1[Well]
RETURN
CALCULATE (
MAX ( Table2[Category] ),
FILTER (
Table2,
Table2[Well] = currentwell
&& Table1[Number] >= Table2[Start Number]
&& Table1[Number] <= Table2[End Number]
)
)

 

https://www.dropbox.com/s/fnj9itg4kd6z457/jklib.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the link down below.

It is for creating a new column.

 

Picture1.png

 

Goal Column CC =
VAR currentwell = Table1[Well]
RETURN
CALCULATE (
MAX ( Table2[Category] ),
FILTER (
Table2,
Table2[Well] = currentwell
&& Table1[Number] >= Table2[Start Number]
&& Table1[Number] <= Table2[End Number]
)
)

 

https://www.dropbox.com/s/fnj9itg4kd6z457/jklib.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Really appreciate the quick and correct response. I didn't know that you can create columns that import data from other views without a live table-to-table relationship.

 

Thanks again! 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors