Forum Discussion

MiKeZZa's avatar
MiKeZZa
Icon for Post Patron rankPost Patron
6 years ago

Get last known value

Hi all,

 

I'm having problems with getting the last known value with my DAX. I now have:

 

MeasureName = 
VAR maxdate = LASTDATE ( Date[Date] )

var result = 
CALCULATE (
    SUM ( Transactons[Amount] ) + 0,
    Transacties[Action]="Action 23",
    Transacties[Date] <= maxdate,
    ALL(Datum)
)

RETURN result

 

 

But this is doing exactly what I ask in the code; it gives me the SUM of amount for al specific dates BEFORE the max date. But that's not what I want; I want to have the latest available value, not a sum. But I'm stuck at fixing this.

 

Example dataset:

 

1 jan '20 - 100

3 jan '20 - 80

 

Desired output:

1 jan '20 - 100

2 jan '20 - 100

3 jan '20 - 80

 

Current output:

1 jan '20 - 100

2 jan '20 - 100

3 jan '20 - 180

 

Does anybody have an idea?

10 Replies