cancel
Showing results for
Did you mean:  Helper I

## Report Last Non Blank Row

Hi there
I'm trying to create a calculated column that returns the last non blank value by a given date. I've tried several DAX options but can't quite get this working. See data below - in this example I would expect a value of -75.71 for 10/11/21. Faye

2 ACCEPTED SOLUTIONS  Super User

Try this:

Measure=
Var _A = max(table[Date])
If(isblank(max(table[value])),
calculate(max(table[value]),filter(all(table),table[Date]<_A&&table[value]<>blank())),
max(table[value])
)

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.  Helper I

Hi Vahid

No unfortunately no good - not sure what is going on here with the calculation! 7 REPLIES 7  Super User

Try this:

Measure=
Var _A = max(table[Date])
If(isblank(max(table[value])),
calculate(max(table[value]),filter(all(table),table[Date]<_A&&table[value]<>blank())),
max(table[value])
)

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.  Helper I

Hi Vahid

No unfortunately no good - not sure what is going on here with the calculation!   Super User

Try this:

``````Meas1ure =
VAR _A =
MAX ( table[Date] )
VAR _B =
CALCULATE (
MAX ( table[Date] ),
FILTER ( ALL ( table ), table[Date] < _A && table[value] <> BLANK () )
)
RETURN
IF (
ISBLANK ( MAX ( table[value] ) ),
CALCULATE ( MAX ( table[value] ), FILTER ( ALL ( table ), table[Date] = _B ) ),
MAX ( table[value] )
)``````

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.  Helper I

@Vahid got it - it was filter context - wanted ALLSELECTED not ALL. Thank you!  Helper I

@VahidDM any ideas on how to calculate as a column? Those values are Lat/Lon that I need to plot on the map & ARCGIS won't work with a measure ...  Super User

Try this to add a column:

``````Column=
VAR _A =
[Date]
VAR _B =
CALCULATE (
MAX ( table[Date] ),
FILTER ( ALL ( table ), table[Date] < _A && table[value] <> BLANK () )
)
RETURN
IF (
ISBLANK ( [value] ),
CALCULATE ( MAX ( table[value] ), FILTER ( ALL ( table ), table[Date] = _B ) ),
[value] )
)``````

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.  Helper I

@VahidDM no not quite - seems like a filter context thing, like it's using a result not from the relevant ID maybe?  Announcements #### The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling. #### Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th! Top Solution Authors
Top Kudoed Authors
Users online (3,557)