cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
T_Findeisen
Frequent Visitor

PowerApps Combine Tables for Search

Hello everybody,

I am pretty new to PowerApps and I am trying to implement a SearchFunction to List outstanding orders.

Requirements are to search for DeliveryAddress, ProductName, SalesId and DeliveryDate.

 

The necessary data is in 3 different tables for Dynamics AX.

SALESTABLE:

  • SALESID (= SALESID IN SALESLINE)
  • DELIVERYDATE
  • SALESSTATUS
  • DELIVERYPOSTALADDRESS (= RECID in LOGISTICSPOSTALADDRESS)

SALESLINE:

  • SALESID (= SALESID IN SALESTABLE)
  • NAME

LOGISTICSPOSTALADDRESS:

  • RECID (= DELIVERYPOSTALADDRESS in SALESTABLE)

After searching through the forums I found the AddColumn/LookUp commands and wrote the following Command into myGallery.Items:

AddColumns(
	Filter(
		'[dbo].[SALESTABLE]';
		DATAAREAID = "USMF";
		CUSTACCOUNT = CustAccountVar1;
		SALESSTATUS = 1 Or SALESSTATUS = 2
	);	
	"DeliveryCity"; 
	LookUp(
		'[dbo].[LOGISTICSPOSTALADDRESS]'; 
		RECID = '[dbo].[SALESTABLE]'[@DELIVERYPOSTALADDRESS]; 
		CITY
	);
	"Product Name";
	LookUp(
		'[dbo].[SALESLINE]';
		SALESID = '[dbo].[SALESTABLE]'[@SALESID];
		NAME
	)
)

I get the following errors in those lines:

RECID = '[dbo].[SALESTABLE]'[@DELIVERYPOSTALADDRESS];
SALESID = '[dbo].[SALESTABLE]'[@SALESID];

'=' gives invalid argument type

'[@...]' gives 'remotely not possible...make formula easier'

 

I am not quite sure what I did wrong because I think the structure is similar to those messages:

https://powerusers.microsoft.com/t5/General-Discussion/Syntax-for-joining-tables/td-p/61387

https://powerusers.microsoft.com/t5/General-Discussion/Using-ClearCollect-to-store-Table-column-valu...

 

Also: The Search implementation is not part of the problem (yet), it was just mentioned to make readers understand the situation.

1 ACCEPTED SOLUTION

Accepted Solutions
v-micsh-msft
Community Support
Community Support

If the two tables contain the same field, then for better performance or misunderstanding, it is recommended to rename a field from one of the two tables.

 

Try the formula below:

ddColumns(
	Filter(
		'[dbo].[SALESTABLE]';
		DATAAREAID = "USMF";
		CUSTACCOUNT = CustAccountVar1;
		SALESSTATUS = 1 Or SALESSTATUS = 2
	);	
	"DeliveryCity"; 
	LookUp(
		'[dbo].[LOGISTICSPOSTALADDRESS]'; 
		RECID = DELIVERYPOSTALADDRESS; 
		CITY
	);
	"Product Name";
	LookUp(RenameColumns(
		'[dbo].[SALESLINE]';"SALESID";"SALESID1");
		SALESID = SALESID1;
		NAME
	)
)

See if this works.

 

Regards,

Michael

Community Support Team _ Michael Shao
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

1 REPLY 1
v-micsh-msft
Community Support
Community Support

If the two tables contain the same field, then for better performance or misunderstanding, it is recommended to rename a field from one of the two tables.

 

Try the formula below:

ddColumns(
	Filter(
		'[dbo].[SALESTABLE]';
		DATAAREAID = "USMF";
		CUSTACCOUNT = CustAccountVar1;
		SALESSTATUS = 1 Or SALESSTATUS = 2
	);	
	"DeliveryCity"; 
	LookUp(
		'[dbo].[LOGISTICSPOSTALADDRESS]'; 
		RECID = DELIVERYPOSTALADDRESS; 
		CITY
	);
	"Product Name";
	LookUp(RenameColumns(
		'[dbo].[SALESLINE]';"SALESID";"SALESID1");
		SALESID = SALESID1;
		NAME
	)
)

See if this works.

 

Regards,

Michael

Community Support Team _ Michael Shao
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

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,061)