cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

Re: PowerApps Combine Tables for Search

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
Highlighted
Community Support
Community Support

Re: PowerApps Combine Tables for Search

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,736)