Forum Discussion
Anonymous
7 years agoNot applicable
get last value from Date
Hello, i am trying to get the last value from a date. This value should be use for the month before which are null. The initial situation looks like that: After a DAX-Function the ...
- 7 years ago
HI, Anonymous
You could try this formula to add a column as below:
Value 2 = VAR CurrentCar = 'Table'[Car] VAR CurrentDate = 'Table'[Month] VAR CurrentRegion = 'Table'[region] VAR LastDateWithValue = IF ( ISBLANK ( 'Table'[Value] ) = FALSE (), 'Table'[month], CALCULATE ( MIN ( 'Table'[month] ), FILTER ( 'Table', 'Table'[car] = EARLIER ( 'Table'[car] ) && 'Table'[region] = EARLIER ( 'Table'[region] ) &&'Table'[month]>=EARLIER('Table'[month]) && ISBLANK ( 'Table'[Value] ) = FALSE () ) ) ) RETURN VAR A = CALCULATE ( LASTNONBLANK( 'Table'[Value], 'Table'[Value] ), FILTER ( 'Table', 'Table'[Car] = CurrentCar && 'Table'[Month] = LastDateWithValue && 'Table'[region] = CurrentRegion ) ) RETURN IF ( ISBLANK ( 'Table'[Value] ), A, 'Table'[Value] )Result:
Deeper testing
Best Regards,
Lin
v-lili6-msft
7 years agoCommunity Support
HI, Anonymous
You could try this formula to add a column as below:
Value 2 =
VAR CurrentCar = 'Table'[Car]
VAR CurrentDate = 'Table'[Month]
VAR CurrentRegion = 'Table'[region]
VAR LastDateWithValue =
IF (
ISBLANK ( 'Table'[Value] ) = FALSE (),
'Table'[month],
CALCULATE (
MIN ( 'Table'[month] ),
FILTER (
'Table',
'Table'[car] = EARLIER ( 'Table'[car] )
&& 'Table'[region] = EARLIER ( 'Table'[region] )
&&'Table'[month]>=EARLIER('Table'[month])
&& ISBLANK ( 'Table'[Value] ) = FALSE ()
)
)
)
RETURN
VAR A =
CALCULATE (
LASTNONBLANK( 'Table'[Value], 'Table'[Value] ),
FILTER (
'Table',
'Table'[Car] = CurrentCar
&& 'Table'[Month] = LastDateWithValue
&& 'Table'[region] = CurrentRegion
)
)
RETURN
IF ( ISBLANK ( 'Table'[Value] ), A, 'Table'[Value] )
Result:
Deeper testing
Best Regards,
Lin
Anonymous
7 years agoNot applicable
thanks! This works :-)
Best regards
Alex