且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

查找函数返回第一条记录,但我想要最后一条记录。

更新时间:2022-10-14 18:49:25

你好jbrowneireland,


根据你的描述,查找主要用于1比1的关系。对于您的情况,我建议考虑使用Lookupset函数来获取目标数据的数组。然后,找到数组的最后一个元素。


这是我的代码供你参考:

 =( (!字段site_id.Value,字段site_id.Value,字段ProjectStatusReports.Value,"!DataSet2&QUOT)Lookupset!!)(UBOUND(Lookupset(字段site_id.Value,字段site_id.Value,字段ProjectStatusReports.Value,&QUOT ; DataSet2")))


有关的更多信息
lookupset
ubound



希望这有帮助



***的问候,


卢卡斯跨度>


Hi,

I have two SharePoint lists defined as Datasets in s-s-rS. 

List 1| Dataset 1 - Project Information - Contains one item.  

List 2 | Dataset 2 - Project Status Reports - Contains multiple items. 

These lists are joined by primary/foreign key called site_id that create a one to many relationship: 

Project Information 1 - N Project Status Reports 

In s-s-rS I am trying to create a table using Dataset 1 that pulls the ONLY the last status report from Dataset 2.  

Using Lookup function, I appear very close, however, it returns the first status report and not the last.

If you can advise I would greatly appreciate it. Thanks. 


Hi jbrowneireland,

According to your description, lookup is used mostly for 1 to 1 relationship. For your case I suggest to consider use Lookupset function to get the array of target data. Then, find the last element of the array.

Here is my code for your reference:

=(Lookupset(Fields!site_id.Value,Fields!site_id.Value,Fields!ProjectStatusReports.Value,"DataSet2"))(Ubound(Lookupset(Fields!site_id.Value,Fields!site_id.Value,Fields!ProjectStatusReports.Value,"DataSet2")))

More information about lookupset and ubound

Hope this helps

Best regards,

Lukas