cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Impactful Individual

## Get the last non blank value of a column with DAX

I want a Column to find the last non blank value from "Class" following the order of the "Date" column.

Thus, the first 3 rows will be empty.

Rows from 31/01/2016 to 30/04/2016 will be A.

And ALL the remaing rows will be B.

I know the following will work:

Coluna =
VAR DataMax = CALCULATE(MAX(Tabela[Data]), FILTER(ALL(Tabela), Tabela[Data]<= EstaData && LEN(Tabela[Class])>0))
RETURN
CALCULATE(MAX(Tabela[Class]), FILTER(ALL(Tabela), Tabela[Data] = DataMax))

But... isn't there a better/cleaner way??

Thanks for helping!

1 ACCEPTED SOLUTION
Community Support

Hi @webportal ,

You can create a calculated column as below：

``````Coluna =
CALCULATE (
LASTNONBLANK ( 'Tabela'[Class], MAX ( 'Tabela'[Data] ) ),
ALL ( 'Tabela' )
)``````

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Regular Visitor

Can you tell me more why this formula work ? Why use min function ?

Community Support

Hi @webportal ,

You can create a calculated column as below：

``````Coluna =
CALCULATE (
LASTNONBLANK ( 'Tabela'[Class], MAX ( 'Tabela'[Data] ) ),
ALL ( 'Tabela' )
)``````

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Impactful Individual

@v-yiruan-msftThank you!

Microsoft Employee

Please try this measure expression, replacing T1 with your actual table name.

LNBV = LASTNONBLANKVALUE(T1[Date], MIN(T1[Class]))
Pat

Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.