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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
clint_powell
Frequent Visitor

Lookup the earliest instance of an entry in a table with multiple values

I have a table structured simliarly to the format below. Each entry has a unique entry ID and entry date, but the same user ID has multiple entries over time. I am trying to write a lookup where the User ID is in a new table, with an added column that returns the Entry ID associated with the earliest Entry Date. This would be similar to a MINIFS statement in Excel. Any help is hugely appreciate!!!

 

Entry IDUser IDEntry Date  User IDFirst Entry ID
111011/19/2024 11011
211021/20/2024 11022
311031/21/2024 11033
411011/22/2024 11047
511021/23/2024   
611031/24/2024   
711041/25/2024   
811011/26/2024   
911031/27/2024   
1011031/28/2024   
2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@clint_powell 

you can try 

Column = CALCULATE(min('Table'[Entry ID]),RELATEDTABLE('Table'))


or


Column 2 = 
VAR _date=CALCULATE(min('Table'[Entry Date ]),RELATEDTABLE('Table'))
return maxx(FILTER('Table','Table'[Entry Date ]=_date),'Table'[Entry ID])

11.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

v-jianpeng-msft
Community Support
Community Support

Hi, @clint_powell 

I'm happy to answer your questions. Here I offer my solution,First of all, we filter out the smallest entry date by MINX function. To obtain the _mindate, we use the calculate function to find the corresponding Entry ID.

The test data is as follows:

Table 1 (Tabelle1):

17.png

Sheet1:

18.png

We can use the following dax formula:

First Entry ID = 
var _userid ='Sheet1'[User ID]
var _mindate = MINX(FILTER('Table 1 (Tabelle1)','Table 1 (Tabelle1)'[User ID]=_userid),'Table 1 (Tabelle1)'[Entry Date ])
VAR _id = CALCULATE(SUMX('Table 1 (Tabelle1)','Table 1 (Tabelle1)'[Entry ID]),'Table 1 (Tabelle1)'[Entry Date ]=_mindate)
RETURN _id

The screenshot of the formula is below:

19.png

The relationship between the tables is as follows:

20.png

The results are as follows:

21.png

When we change the date, the latest first entry ID will be automatically updated

22.png

The latest results are as follows:

23.png

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-jianpeng-msft
Community Support
Community Support

Hi, @clint_powell 

I'm happy to answer your questions. Here I offer my solution,First of all, we filter out the smallest entry date by MINX function. To obtain the _mindate, we use the calculate function to find the corresponding Entry ID.

The test data is as follows:

Table 1 (Tabelle1):

17.png

Sheet1:

18.png

We can use the following dax formula:

First Entry ID = 
var _userid ='Sheet1'[User ID]
var _mindate = MINX(FILTER('Table 1 (Tabelle1)','Table 1 (Tabelle1)'[User ID]=_userid),'Table 1 (Tabelle1)'[Entry Date ])
VAR _id = CALCULATE(SUMX('Table 1 (Tabelle1)','Table 1 (Tabelle1)'[Entry ID]),'Table 1 (Tabelle1)'[Entry Date ]=_mindate)
RETURN _id

The screenshot of the formula is below:

19.png

The relationship between the tables is as follows:

20.png

The results are as follows:

21.png

When we change the date, the latest first entry ID will be automatically updated

22.png

The latest results are as follows:

23.png

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@clint_powell 

you can try 

Column = CALCULATE(min('Table'[Entry ID]),RELATEDTABLE('Table'))


or


Column 2 = 
VAR _date=CALCULATE(min('Table'[Entry Date ]),RELATEDTABLE('Table'))
return maxx(FILTER('Table','Table'[Entry Date ]=_date),'Table'[Entry ID])

11.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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