Forum Discussion

ElvirBotic's avatar
ElvirBotic
Icon for Helper III rankHelper III
3 years ago
Solved

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

 

DateColumn 1column 2column 3column4
01/20/20234.52.271
02/22/20235.53.0511
03/08/20235.34102
04/15/20235.25 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's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity 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