Forum Discussion
Return Latest Value in a column using DAX
Hello, I am stuck on what seems to be an easy problem, but I am having no luck returning the correct value. I want to to be able to return the latest value in a column of a table. I have a date column and the columns are % columns that are calculated at the source level and I want to display on a card the most recent % from the 5 columns we have.
I tried using lastnonblank, but had no success. I also tried using an index as I saw different solution minding the max value using an index. This is the measure I used with the index CALCULATE(LASTNONBLANK(Table[Column], 1), FILTER(ALL(Table), Table[Index] = MAX(Table[Index])))
The cards should display...
card 1: 5.2
card 2: 6
card 3: 10
card 4: 4
Here is a sample table
| Date | Column 1 | column 2 | column 3 | column4 |
| 01/20/2023 | 4.5 | 2.2 | 7 | 1 |
| 02/22/2023 | 5.5 | 3.0 | 5 | 11 |
| 03/08/2023 | 5.3 | 4 | 10 | 2 |
| 04/15/2023 | 5.2 | 5 | 3 | |
| 05/20/2023 | 6 | 4 | ||
| 06/25/2023 | ||||
| 0718/2023 |
ElvirBotic Should be something like:
Card 1 Measure = VAR __Table = FILTER( 'Table', [Column 1] <> BLANK() ) VAR __MaxDate = MAXX( __Table, [Date] ) VAR __Result = MAXX( FILTER( __Table, [Date] = __MaxDate ), [Column 1] ) RETURN __Result
1 Reply
- Greg_Deckler
Community Champion
ElvirBotic Should be something like:
Card 1 Measure = VAR __Table = FILTER( 'Table', [Column 1] <> BLANK() ) VAR __MaxDate = MAXX( __Table, [Date] ) VAR __Result = MAXX( FILTER( __Table, [Date] = __MaxDate ), [Column 1] ) RETURN __Result