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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cookm
Frequent Visitor

Measure or Column with Bridge Table

This should be simple as it is a wash in SQL. However I am having no luck. TABLE A has measured DEPTHS per RAIL. TABLE B assigns COLOR between TOP and BOTTOM depths. Because this is a many-to many relationship, I created a bridge table (TABLE C) with one to many joins to both the A and B tables. The end result I am trying to achieve is that if the Table A RAIL = TABLE B RAIL and the TABLE A DEPTH falls between the TABLE B TOP and BOTTOM depths then post the TABLE B COLOR. I either get blanks or True/False. Please provide me the correct DAX formula to accomplish this.

 

cookm_0-1674852776478.png

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @cookm 

 

You can try the following methods.

Color = 
CALCULATE ( MAX ( 'Table B'[COLOR] ),
    FILTER ( ALL ( 'Table B' ),
        [RAIL] = EARLIER ( 'Table A'[RAIL] )
            && [TOP] <= EARLIER ( 'Table A'[DEPTH] )
            && [BOTTOM] >= EARLIER ( 'Table A'[DEPTH] )
    )
)

vzhangti_0-1675061473029.png

Measure = 
CALCULATE ( MAX ( 'Table B'[COLOR] ),
    FILTER ( ALL ( 'Table B' ),
        [RAIL] = SELECTEDVALUE( 'Table A'[RAIL] )
            && [TOP] <= SELECTEDVALUE ( 'Table A'[DEPTH] )
            && [BOTTOM] >= SELECTEDVALUE( 'Table A'[DEPTH] )
    )
) 

vzhangti_1-1675061705143.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @cookm 

 

You can try the following methods.

Color = 
CALCULATE ( MAX ( 'Table B'[COLOR] ),
    FILTER ( ALL ( 'Table B' ),
        [RAIL] = EARLIER ( 'Table A'[RAIL] )
            && [TOP] <= EARLIER ( 'Table A'[DEPTH] )
            && [BOTTOM] >= EARLIER ( 'Table A'[DEPTH] )
    )
)

vzhangti_0-1675061473029.png

Measure = 
CALCULATE ( MAX ( 'Table B'[COLOR] ),
    FILTER ( ALL ( 'Table B' ),
        [RAIL] = SELECTEDVALUE( 'Table A'[RAIL] )
            && [TOP] <= SELECTEDVALUE ( 'Table A'[DEPTH] )
            && [BOTTOM] >= SELECTEDVALUE( 'Table A'[DEPTH] )
    )
) 

vzhangti_1-1675061705143.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

FreemanZ
Super User
Super User

hi @cookm 

try to create a calculated column in TableA like:

COLOR =
VAR _depth = [DELPTH]
VAR _rail = [RAIL]
VAR _table =
FILTER(
    TableB,
    TableB[RAIL] = _rail
         &&TableB[TOP] >= _depth
         &&TableB[BUTTOM] <= _depth
)
RETURN
MINX(_table, TableB[COLOR])
 
You don't need the bridge table in this way.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors