Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Daniel_Fdrvc
Helper I
Helper I

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?

 

image001.png

1 ACCEPTED SOLUTION
Daniel_Fdrvc
Helper I
Helper I

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. 

View solution in original post

5 REPLIES 5
Daniel_Fdrvc
Helper I
Helper I

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. 

v-kkf-msft
Community Support
Community 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

vkkfmsft_0-1643961972585.png

 

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.

Greg_Deckler
Super User
Super User

@Daniel_Fdrvc Perhaps:

Latest value column =
  VAR __Rows = SELECTCOLUMNS('Table2',"__LatestValues",[Latest value])
RETURN
  IF("no" IN __Rows,"no","yes")

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler this add's to all unique id's in 1 table same value, for example - yes 😞

@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")

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.