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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Hasvine2022
Helper I
Helper I

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

@Hasvine2022 , 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 @Hasvine2022 ,

 

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 @Hasvine2022 ,

 

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

@Hasvine2022 , a new column in Stock_main

 

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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