Forum Discussion

leolapa_br's avatar
leolapa_br
Resolver II
1 year ago
Solved

Get First Value From A Column

Hi have a table called "StockQuotes" that looks like this: I wrote the following code as an attempt to fetch the first available (from the earliest date) Close Price for each respective stock ...
  • leolapa_br's avatar
    1 year ago

    ChatGTP came to the rescue here and produced the following code that solved the issue:

    First Close = 
    CALCULATE(
        FIRSTNONBLANK(StockQuotes[Close Price], 1),
        FILTER(
            ALL(StockQuotes),
            StockQuotes[Ticker] = SELECTEDVALUE(StockQuotes[Ticker]) &&
            StockQuotes[Date] = 
                CALCULATE(
                    MIN(StockQuotes[Date]),
                    ALLEXCEPT(StockQuotes, StockQuotes[Ticker])
                )
        )
    )