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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
baronraghu_3011
Frequent Visitor

Lookupvalue trouble

Hi All,

 

I need to pickup the last traded price of a particular stock into a new table

 

Table 1  has last 5 years historic data of stock - ABC 

Table 2 has list of stock names

 

i was trying Lookupvalue measure but somehow the measure was not picking a column in the search value

 

This is what i used - LOOKUPVALUE(Table1[Stock Price], Table1[Stock_Name],Table2[Stock Name],Table1[Date],Today()-1) 

 

However This doesnt seem to give the result. Many Tanks for your support

1 ACCEPTED SOLUTION

@baronraghu_3011 
Could it be that there are multiple transactions in one day for a stock name? If there is more than one transaction, it cannot be converted to a scalar value. If this is the case, you can take the maximum stock price per day, for example.

last traded price of stock =
CALCULATE (
    MAX ( Table1[Stock Price] ),
    Table1[Date]
        = TODAY () - 1,
    ALLEXCEPT ( Table2, Table2[Stock Name] )
)

View solution in original post

3 REPLIES 3
baronraghu_3011
Frequent Visitor

Hi,

 

I tried doing as you said, the formula didn give me any error but however, the return value was blank

@baronraghu_3011 
Could it be that there are multiple transactions in one day for a stock name? If there is more than one transaction, it cannot be converted to a scalar value. If this is the case, you can take the maximum stock price per day, for example.

last traded price of stock =
CALCULATE (
    MAX ( Table1[Stock Price] ),
    Table1[Date]
        = TODAY () - 1,
    ALLEXCEPT ( Table2, Table2[Stock Name] )
)
Barthel
Solution Sage
Solution Sage

@baronraghu_3011,
If the tables are connected by a relationship (Table1[Stock Name] and Table2[Stock Name]), you could use CALCULATE instead of the LOOKUPVALUE. CALCULATE is often a better alternative. You could set up a calculated column using CALCULATE like this:

last traded price of stock =
CALCULATE (
    SELECTEDVALUE ( Table1[Stock Price] ),
    Table1[Date]
        = TODAY () - 1,
    ALLEXCEPT ( Table2, Table2[Stock Name] )
)

Use ALLEXCEPT to avoid a possible circular reference.

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.