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