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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ddalton
Resolver I
Resolver I

Creating new columns from another table based on two criteria

I have the following tables. Note "..." represents similar data or arbitrary values etc.

 

TBL1

REFSTG_IDIDSMPL_IDSMPL_NUME1E2E3E4E5E6E7
884-A129711111010.50538
884-A129711221110.50528
884-A22971111100.50.60325
884-A22971122.....................
335-B12971133.....................
335-B12971144.....................
350-E12721155.....................
350-E12721166.....................
350-E22721155.....................
...           

 

TBL2

IDEXMINMAX
297E1811
297E20.51.5
297E300.6
............
297E767.5
272E1811
272E20.51.5
272E300.6
............
272E767.5
............

 

I have created the following relationship between the tables:

TBL1*:*TBL2

 

The relationship currently filters in both directions. 

 

I would like to create new columns in TBL1 that correspond to the MIN and MAX values of the respective ID and EX in TBL2, i.e., an E1_min, E1_max, E2_min, E2_max column etc. similar to below

 

REFSTG_IDIDSMPL_IDSMPL_NUME1E1_minE1_maxE2E2_minE2_max...
884-A129711111081110.51.5...
884-A129711221181110.51.5...

 

The MIN and MAX values should not differ for rows with the same ID so some kind of a lookup for the ID and EX values should be sufficient. 

 

I've achieved similar things before but only based on a single criteria and using either a LOOKUPVALUE or a CALCULATE with FILTER etc. 

 

I'd be grateful for any recommendations on how to achieve it. 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ddalton , unpivot table 2 in power query and then merge

 

https://radacad.com/pivot-and-unpivot-with-power-bi

merge: https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

Or try column in table 1 like

 

maxx(filter(Table2, Table2[ID] = Table1[ID] && Table2[EX] ="E1") , Table2[Min])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@ddalton , unpivot table 2 in power query and then merge

 

https://radacad.com/pivot-and-unpivot-with-power-bi

merge: https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

Or try column in table 1 like

 

maxx(filter(Table2, Table2[ID] = Table1[ID] && Table2[EX] ="E1") , Table2[Min])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

The MAXX and FILTER expression seems to be doing the trick but I will try a merge later too, and come back with my preferred solution. Regardless, I'll mark your answer as the solution! 

 

Thanks. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors