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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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]  )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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]  )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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