Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Pulling most recent value

Hi all,

 

For some reason I am struggling to figure out how to pull the last value, the column is a calculated column (each row contains a 0 or 1 the field has been set to average). When I put the data in a table visual....

 

DateProduct Sales
1/1/202219.00%
1/6/202222.00%

 

I was playing around with the following to try and get the 22.00%....obviously not working for me

% Product Sales = 
CALCULATE(
SUM(Table[Product Sales]),
FILTER(TABLE, TABLE[Product Sales] = LASTDATE(ALLSELECTED(TABLE[Date]))))

 

Any help would be appreciated

 

 

 

5 Replies

  • Anonymous , Try like

     

    lastnonblankvalue(TABLE[Date],SUM(Table[Product Sales]))

  • Saap's avatar
    Saap
    Resolver III

    Hi Anonymous 

    Maybe try to use this measure:

    % product sales =
    var MaxDate = CALCULATE(MAX('Table'[Date]), ALL('Table'))

    return

    CALCULATE(MAX('Table'[Product Sales]), FILTER('Table','Table'[Date]=MaxDate))

    It display this value when put into card visual.

     

    • danextian's avatar
      danextian
      Super User

      Hi Saap ,

       

      Try this measure below. Change the table and column names accordingly

      Value of the latest date =
      VAR __MAX_DATE =
          CALCULATE ( MAX ( Dates[Date] ), ALLSELECTED ( Dates ) ) //ALLSELECTED for the max date in the current filter context, ALL for the max date in the Dates table regardless of the filters applied
      RETURN
          CALCULATE ( [Sum of Values], Dates[Date] = __MAX_DATE )

       sample result -