Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Retreiving the latest value from a table

Hi!
I am trying to pull out the latest value, substract it from a fixed value in other table, and display the result. I only just started DAX and would appreciate help with the probably very simple task...

 

Table1 has three basic columns and a couple of thousand rows:

Index  - Unique integer

Time - Recorded time in time format

Value1 - Decimal value

 

Table2 has a contant value2.

 

The simple result I am looking for is hence something like LatestTotal = (Latest) Value1 - Value2.

 

Thanks!

 

 

  • Hi Anonymous 

    is there any relationships between table1 and table2?

    anyway, try a measure

    LatestTotal = 
    var lastDataTbl1 = calculate(max('Table1'[Time]);ALL('Table1'))
    var lastDataTbl2 = calculate(max('Table2'[Time]);ALL('Table2'))
    RETURN 
    calculate(
    SUM('Table1'[Value1]); FILTER(ALL('Table1');'Table1'[Time]=lastDataTbl1)
    ) - 
    calculate(
    SUM('Table2'[Value2]); FILTER(ALL('Table2');'Table2'[Time]=lastDataTbl2)
    )

    do not hesitate to give a kudo to useful posts and mark solutions as solution

5 Replies