Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
FayeB1901
Helper I
Helper I

Report Last Non Blank Row as a column

Hi All 

 

Putting this one out there again as I wasn't able to get a working solution. I've got a measure to do this, but I need  a calculated column. This is because the data is latitudes which ARC GIS can't plot in a map without having an individual row context. 

 

Options include:

1. A calculated column
2. Possibly a summary table?

Any feedback appreciated. See summary table below showing the problem. The highlighted values are pulling the last non blank value in the data set so suspect there is some DAX missing to delineate between IDs, could it be that simple? 

FayeB1901_0-1638747123654.png

Thanks
Faye

 

 

1 ACCEPTED SOLUTION

You want the last nonblank prior to the date in the current row?

 

Add an extra condition to your MaxDate calculation:

Last Lat =
VAR CurrDate = Table1[Date]
VAR MaxDate =
    CALCULATE (
        MAX ( Table1[Date] ),
        ALLEXCEPT ( Table1, Table1[ID] ),
        NOT ( ISBLANK ( Table1[Lat] ) ),
        Table1[Date] <= CurrDate
    )
RETURN
    CALCULATE (
        MAX ( Table1[Lat] ),
        ALLEXCEPT ( Table1, Table1[ID] ),
        Table1[Date] = MaxDate
    )

View solution in original post

4 REPLIES 4
FayeB1901
Helper I
Helper I

Thank you, appreciate this 🙂

AlexisOlson
Super User
Super User

You can certainly get the last Lat per ID.

Last Lat =
VAR MaxDate =
    CALCULATE (
        MAX ( Table1[Date] ),
        ALLEXCEPT ( Table1, Table1[ID] ),
        NOT ( ISBLANK ( Table1[Lat] ) )
    )
RETURN
    CALCULATE (
        MAX ( Table1[Lat] ),
        ALLEXCEPT ( Table1, Table1[ID] ),
        Table1[Date] = MaxDate
    )

The ALLEXCEPT here is specifying that we want to match only the ID column.

Hmm close but not quite, this returns last non blank row overall, not the last non blank row based on the current row, if that makes sense?

FayeB1901_2-1638750368072.png

 

You want the last nonblank prior to the date in the current row?

 

Add an extra condition to your MaxDate calculation:

Last Lat =
VAR CurrDate = Table1[Date]
VAR MaxDate =
    CALCULATE (
        MAX ( Table1[Date] ),
        ALLEXCEPT ( Table1, Table1[ID] ),
        NOT ( ISBLANK ( Table1[Lat] ) ),
        Table1[Date] <= CurrDate
    )
RETURN
    CALCULATE (
        MAX ( Table1[Lat] ),
        ALLEXCEPT ( Table1, Table1[ID] ),
        Table1[Date] = MaxDate
    )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.