Forum Discussion
Create new table with last complete record for each Unit
Unfortunately it is the ties in the [Lastchanged] column that is causing the TopN to return more than 1 row for some DUID.
Would be useful if there was a parameter in TopN to explicitly return 1 row only - something similar to the RankX.
Tried wrapping the function in LastNONBlank to explicitly return only 1 row, but this doesn't appear to work, probably something to do with operation on a column argument rather than a complete table row.
For me, its quicker to simply export the 616 of 678 table out and remove the highlighted duplicates in excel.
I don't know if it is ok for you to create an auxiliary column, but if it is ok, here is my solution:
Create the ISMAX column to check if it is the last record.
Then, create your virtual table with DISTINCT of only "Yes".
- zapppsr8 years ago
Kudo Collector
ISMAX =
VAR DUID = Tabela1[DUID]
VAR MAXDATE =
CALCULATE (
MAX ( Tabela1[LASTCHANGED] );
ALL ( Tabela1 );
Tabela1[DUID] = DUID
)
RETURN
IF ( Tabela1[LASTCHANGED] = MAXDATE; "Yes"; "No" )UniqueDUID =
CALCULATETABLE ( DISTINCT ( Tabela1 ); Tabela1[ISMAX] = "Yes" ) - pat_energetics8 years ago
Advocate II
Thanks zapppsr, I thought your function would work.
When I filter the original table on the ISMAX column = "Yes" , it still returns 678 values (of which 616 are unique)
When I use the CALCULATETABLE with filter on the ISMAX, it still returns 678 records - with 616 unique.
The issue is due to the ties in the [LASTCHANGED] for some DUID, which is an issue in the source that cannot be changed.
In the meantime I have fixed the duplicates in excel.
Thanks for trying !
- zapppsr8 years ago
Kudo Collector
I guess the tie is on a combination of other columns beside DUID and LASTCHANGED, because I treated the tie for those two columns. Have you considered testing creating a table with only those columns?