Problem with LOOKUPVALUE

Hello,

Is it possible to get an “selectedvalue” in a DAX formula with LOOKUPVALUE?

The problem is that I would like to have the First MileageKms for a particular vehicleID/ licenseNo in a particular period. I tried the function Lookupvalue, but I can’t get the searchvalue for the VehicleID correct (340, then 334, then 337 – based on the context) in the function.

DAX formula:
Mileage search (FIRST DATE) = LOOKUPVALUE(RefuellingStops[MileageKms];RefuellingStops[VehicleId];340;RefuellingStops[Moment];[First date])

Greetings Marc from the Netherlands

@MarcSpr
Can you upload a some sample data via a pbix file along with what you would like the final output to be?

-Nick

Fuel consumption.pbix (450.0 KB)

@MarcSpr
Please take a look and see if this is what you had in mind:

First Refilling Date = 
CALCULATE(
    FIRSTDATE(RefuellingStops[Moment]),
    FILTER(
        ALL(RefuellingStops),
        RefuellingStops[VehicleId] = SELECTEDVALUE(RefuellingStops[VehicleId])
    )
)

First Refilling Mileage = 
CALCULATE(
    SUM(RefuellingStops[MileageKms]),
    FILTER(
        ALL( Datums ),
        [First Refilling Date] = Datums[Datum (kort)]
    )
)

Yes! This is what i wanted!

Thanks!