Forum Discussion

Daniel_Fdrvc's avatar
Daniel_Fdrvc
Icon for Helper I rankHelper I
4 years ago
Solved

Add latest value from one table to another

Hello,

 

i've got some issues with adding latest value from one table to another, maybe someone could help me. So.. I've created new calculated table that stores distinct UNIQUE ID values from two other tables (1 table on attached screen). In third table (2 table) i have unique id's, some values, dates and calculated column, that calculates lates value by date for that ID. Now i need to add that calculated latest value from 2 table to a 1 table. Relations betweens this tables looks like 1 to * and that's the issue - the formula does not know which value to transfer from 2 table to 1 table. How can i solve that? Any suggestions?

 

  • You won't believe... because latest value for same ID is always the same, even if that ID appears two or more times, simple lookupvalue function solves me everything. 

5 Replies

  • You won't believe... because latest value for same ID is always the same, even if that ID appears two or more times, simple lookupvalue function solves me everything. 

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Daniel_Fdrvc Perhaps:

    Latest value column =
      VAR __Rows = SELECTCOLUMNS('Table2',"__LatestValues",[Latest value])
    RETURN
      IF("no" IN __Rows,"no","yes")
      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        Daniel_Fdrvc I assumed the tables were related to one another, try:

        Latest value column =
          VAR __ID = [Unique ID]
          VAR __Rows = SELECTCOLUMNS(FILTER('Table2',[ID] = __ID),"__LatestValues",[Latest value])
        RETURN
          IF("no" IN __Rows,"no","yes")
  • v-kkf-msft's avatar
    v-kkf-msft
    Icon for Community Support rankCommunity Support

    Hi Daniel_Fdrvc ,

     

    Please try the following formula:

     

    Latest value = 
    VAR latestDate =
        CALCULATE (
            MAX ( 'Table 2'[Date] ),
            FILTER ( 'Table 2', 'Table 2'[ID] = 'Table 1'[Unique ID] )
        )
    VAR latestValue =
        MAXX (
            FILTER (
                'Table 2',
                'Table 2'[ID] = 'Table 1'[Unique ID]
                    && 'Table 2'[Date] = latestDate
            ),
            'Table 2'[Value]
        )
    RETURN
        latestValue

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.