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
Hyperchef1969
Helper V
Helper V

Lookup on different tables by unique concatenated search criteria

Hi,

 

I have two tables, one is the inventory table, the other is the transaction table. See below printscreen. What I am trying to achieve is the following: In the on hand table I want the comment to be displayed from the material transaction table (value column K displayed in column E). I want a lookup from the combination article number and subinventory from the on hand table, to the article and subinventory from the material transaction table. This my search criteria (in excel I build it in column D and H). To be displayed in the inventory table (column E) should be the comment of the maximum transaction date (column I) in relation to my search criteria. How should I achieve this by Power BI and dax? Step by step please. Many thanks in advance for your help!

 

Capture.PNG

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Hyperchef1969 ,

 

Please try to add a calculated column in the Inventory table:

Comment =
VAR _a =
    MAXX (
        FILTER (
            'Transaction',
            [Search criteria] = EARLIER ( Inventory[Search criteria] )
        ),
        [Transaction date]
    )
RETURN
    CALCULATE (
        MAX ( 'Transaction'[Comment] ),
        FILTER (
            'Transaction',
            [Search criteria] = EARLIER ( 'Inventory'[Search criteria] )
                && [Transaction date] = _a
        )
    )

Final output:

vjianbolimsft_0-1670823024744.png

Best Regards,

Jianbo Li

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-jianboli-msft
Community Support
Community Support

Hi @Hyperchef1969 ,

 

Please try to add a calculated column in the Inventory table:

Comment =
VAR _a =
    MAXX (
        FILTER (
            'Transaction',
            [Search criteria] = EARLIER ( Inventory[Search criteria] )
        ),
        [Transaction date]
    )
RETURN
    CALCULATE (
        MAX ( 'Transaction'[Comment] ),
        FILTER (
            'Transaction',
            [Search criteria] = EARLIER ( 'Inventory'[Search criteria] )
                && [Transaction date] = _a
        )
    )

Final output:

vjianbolimsft_0-1670823024744.png

Best Regards,

Jianbo Li

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

Bifinity_75
Solution Sage
Solution Sage

Hi @Hyperchef1969 , try this:

- Create a calculate column in your transaction table:

Search_Criteria2 = IF (CALCULATE(max('Transaction table'[Transaction date]),
ALLEXCEPT('Transaction table','Transaction table'[Search_Criteria]))='Transaction table'[Transaction date],
'Transaction table'[Search_Criteria],"xxx")

 

- And in your Inventory table, create this calculate column:

Comment__ = 
maxx(filter('Transaction table' , 
        search('Transaction table'[Search_Criteria2],'Inventory Table'[Search Criteria],,0)>0),
        'Transaction table'[Comment])

Best Regards

 

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.