Sort by most recent row

ANY(SELECT(Vistorias[CONCATS],[_THISROW].[TP Nº]=[TP Nº]))

I'm trying to make the result of this expression always display the most recent item in the table. However, it always displays the first item.
I tried using ORDERBY like this:

ANY(ORDERBY(SELECT(Vistorias[CONCATS],[_THISROW].[TP Nº]=[TP Nº]),[Data de Vist]))

however, I get as a return:

ORDERBY tem entradas inválidas.
Solved Solved
0 2 134
1 ACCEPTED SOLUTION

ORDERBY requires a list of row keys and then sorts the rows DESCENDING accordingly.  You would then need to SELECT the column value that matches the TOP sorted row. 

Not to bad to create but instead I would use MAXROW like this:

ANY(SELECT(Vistorias[CONCATS], 
       [row key] = MAXROW("Vistorias", "Data de Vist", [_THISROW].[TP Nº]=[TP Nº])
))

NOTE:  you will need to replace "row key" with the column of the table key column.

View solution in original post

2 REPLIES 2

ORDERBY requires a list of row keys and then sorts the rows DESCENDING accordingly.  You would then need to SELECT the column value that matches the TOP sorted row. 

Not to bad to create but instead I would use MAXROW like this:

ANY(SELECT(Vistorias[CONCATS], 
       [row key] = MAXROW("Vistorias", "Data de Vist", [_THISROW].[TP Nº]=[TP Nº])
))

NOTE:  you will need to replace "row key" with the column of the table key column.

Oh, ty very much! 

Top Labels in this Space