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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Vlookup the latest price

Hello Team,

 

I need help creating a new column in a table.

 

My tables are as follows:

 

Table Stock_main:

DateDescriptionBalance
28/01/2022Sugar5.00
28/01/2022Sugar4.00
28/01/2022Soda3.00
27/01/2022Chicken7.00
26/01/2022Chicken5.00

 

 

Purchasing table:

DatedesUnit price
03/01/2022Sugar10.00
01/01/2022Sugar8.00
01/01/2022Soda15.00
01/01/2022Chicken100.00
31/12/2022Chicken110.00

 

I need to vlookup the latest unit price in the table Stock_main from the purchasing table.

 

I appreciate your help.

 

Kind Regards,

 

Hasvine

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , a new column in Stock_main

 

MAxx(filter(Purchasing, Purchasing[des] =Stock_main[Description] && Purchasing[Date] <=Stock_main[Date]) ,Purchasing[Date]  )

View solution in original post

Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

It required bit of modelling where you need to create a calender table and join these table with it.

Then create a column as below:-

latest_unit_Price = 
VAR _max_date =
    CALCULATE (
        MAX ( 'Purchasing table'[Date] ),
        FILTER (
            'Purchasing table',
            'Purchasing table'[description] = Stock_main[Description]
        )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Purchasing table'[Unit price] ),
        FILTER ( 'Purchasing table', 'Purchasing table'[Date] = _max_date )
    )

Refer a file below:-

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

It required bit of modelling where you need to create a calender table and join these table with it.

Then create a column as below:-

latest_unit_Price = 
VAR _max_date =
    CALCULATE (
        MAX ( 'Purchasing table'[Date] ),
        FILTER (
            'Purchasing table',
            'Purchasing table'[description] = Stock_main[Description]
        )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Purchasing table'[Unit price] ),
        FILTER ( 'Purchasing table', 'Purchasing table'[Date] = _max_date )
    )

Refer a file below:-

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

amitchandak
Super User
Super User

@Anonymous , a new column in Stock_main

 

MAxx(filter(Purchasing, Purchasing[des] =Stock_main[Description] && Purchasing[Date] <=Stock_main[Date]) ,Purchasing[Date]  )

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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