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
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
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.