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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
heiligbd
Helper I
Helper I

Match Different Rows From Same Table In New Calculated Column

Good Day,

 

So I have a dataset that is looking at inventory metrics at multiple plants. For example, I have determined where I have a plant that is the Primary consumer of a particular material at one plant and therefore in an effort to maximize material consumption, other plants could transfer their like material to them if they are not meeting certain criteria. In the example below, I would like help solving for the "Transfer To" Column by particular material filtered. So that the other plants would know whom to send their materials to get consumed and reduce overall inventory. All of the fields shown are available and I would like a DAX solution to help on this. 

 

Thanks in advance for your help!

 

PlantMaterialRank Consumption Rank Inv TurnsTransferPrimaryTransfer To
A12311NAPrimaryNA
B12343TransferSecondaryA
C12324TransferSecondaryA
D12332TransferSecondaryA
A45623TransferSecondaryB
B45611NAPrimaryNA
C45642TransferSecondaryB
D45634TransferSecondaryB

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @heiligbd ,

 

Not sure if you want a calculated column or a measure but here is the values for both:

Calculated column:

TransferTo =
IF (
    'Table'[Transfer] <> "NA",
    MAXX (
        TOPN (
            1,
            FILTER ( 'Table', 'Table'[Material] = EARLIER ( 'Table'[Material] ) ),
            'Table'[Rank Inv Turns], ASC
        ),
        'Table'[Plant]
    ),
    'Table'[Transfer]
)

 

Measure:

TransferTo _ = 
    IF(SELECTEDVALUE('Table'[Transfer]) <> "NA",MAXX (
        TOPN (
            1,
            FILTER ( ALLSELECTED('Table'[Material], 'Table'[Rank Inv Turns],'Table'[Plant]), 'Table'[Material] = MAX ( 'Table'[Material] ) ),
            'Table'[Rank Inv Turns], ASC
        ),
        'Table'[Plant]
    ), SELECTEDVALUE('Table'[Transfer]))

MFelix_0-1679565808212.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

2 REPLIES 2
heiligbd
Helper I
Helper I

Awesome! Thanks for the help!

MFelix
Super User
Super User

Hi @heiligbd ,

 

Not sure if you want a calculated column or a measure but here is the values for both:

Calculated column:

TransferTo =
IF (
    'Table'[Transfer] <> "NA",
    MAXX (
        TOPN (
            1,
            FILTER ( 'Table', 'Table'[Material] = EARLIER ( 'Table'[Material] ) ),
            'Table'[Rank Inv Turns], ASC
        ),
        'Table'[Plant]
    ),
    'Table'[Transfer]
)

 

Measure:

TransferTo _ = 
    IF(SELECTEDVALUE('Table'[Transfer]) <> "NA",MAXX (
        TOPN (
            1,
            FILTER ( ALLSELECTED('Table'[Material], 'Table'[Rank Inv Turns],'Table'[Plant]), 'Table'[Material] = MAX ( 'Table'[Material] ) ),
            'Table'[Rank Inv Turns], ASC
        ),
        'Table'[Plant]
    ), SELECTEDVALUE('Table'[Transfer]))

MFelix_0-1679565808212.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

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.