cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jup
Level: Powered On

Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

Hi all!

 

my problem:

 

I want to create a gallery with a lookup (join) on 2 tables.

 

My 1st szenario works fine:

 

2.PNG1.PNG

 

As you can see: In the gallery the values from both tables are shown correctly ([TestUser].[name] -and- [TestCostCenter].[Caption].

I used "ThisItem.TestUserRecord.Caption" for the label.

----------------------------

BUT... my 2nd szenario doesn't show the value from the lookup-Table (it's blank and I dont know why):

3.PNG

Here I'll get the items from the table [StockItem] but the values from the table [StockType] is BLANK (???!!!).

I used "ThisItem.StockItemRecord.Caption" for the label.

-----------

The table structure in both szenarios are the same. (Primary Keys...)

The only difference is that in szenario 1 (working szenario) there are only a few records in the both tables.-In szenario 2 (not working - blank items) there are >1000000 items in the tables.

 

Is this a delegation-problem?

please help.

 

thanks

jup

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

Although the abbreviated form worked for my little test sample, you might want to go fully qualified on the names.

 

AddColumns('[dbo].[TestUser]',
      "CostCenterName", Lookup('[dbo].[TestCostCenter]', '[dbo].[TestCostCenter]'[@IdCostCenter]='[dbo].[TestUser]'[@IdCostCenter]).Caption)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

14 REPLIES 14
jup
Level: Powered On

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

Can anyone help me? I do not understand the JOIN of 2 tables and never get the desired result on a gallery.

That can not be that hard or right ?!

Are there any prerequisites for the database (onpremise mssql tables) ?!

I do not understand that... 😕 *crying*

Super User
Super User

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

@jupnot entirely sure why you would want to bring in the full record of the CostCenter table into your current gallery list.  It seems (from what I see) that you have a list of items from the User table.  What else would you want there from the CostCenter table??  And, as I see the screen, you have the ">" navigation that would presumably take you to another screen (or other) that would have the list of looked up items from the CostCenter table in it.

 

So...with that said - trying to elliminate a large pull of data and memory usage when not needed, I believe you might simply be needing the cost center name.

  AddColumns('[dbo].[TestUser]', "CostCenterName", Lookup('[dbo].[TestCostCenter]', IdCostCenter=IdCostCenter)

 

As for the Stock Items - I am not sure what your tables look like.  You didn't supply the info for them.  I assume they are pretty much the same and the logic above should work there too.

 

I don't have the spare time at the moment to do some tests for you, but if you don't figure it out and no one else helps, I'll check on it later.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
jup
Level: Powered On

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

Thank you for your response!

 

If I use your formula

AddColumns('[dbo].[TestUser]'; "CostCenterName"; LookUp('[dbo].[TestCostCenter]'; IdCostCenter=IdCostCenter))

I get the following (wrong) result:

 

4.PNG

 

It has to be:

----

JOHN

Warehouse

----

Rick

IT

----

 

Thanks in advance

jup

NigelP
Level 8

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

Hi @jup

 

1.Is this correct ?    the same variable both sides of the "=" sign  - IdCostCenter=IdCostCenter))

2. Dont you need a ShowColumns somewhere ShowColumns(AddColumns( etc etc?

 

Regards

 

Nigel

Super User
Super User

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

Yeah. I'll check into it in a bit. I'm out of touch for the next few hours.
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Super User
Super User

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

Sorry, been a bit rushed today.  Looking back at the stuff I sent before...

 

Here is what I was aiming for:

   AddColumns('[dbo].[TestUser]',
      "CostCenterName", Lookup('[dbo].[TestCostCenter]', [dbo].[TestCostCenter][@IdCostCenter]=IdCostCenter).Caption)

 

This will give you a datasource for your gallery that is the TestUser records with an added field of CostCenterName that comes from the TestCostCenter Caption field.

For the label in your gallery, your text would be ThisItem.CostCenterName

 

Hope that is clearer and helps.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
jup
Level: Powered On

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

I really dont understand it. 

 

see the picture attached 😞

Super User
Super User

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

Although the abbreviated form worked for my little test sample, you might want to go fully qualified on the names.

 

AddColumns('[dbo].[TestUser]',
      "CostCenterName", Lookup('[dbo].[TestCostCenter]', '[dbo].[TestCostCenter]'[@IdCostCenter]='[dbo].[TestUser]'[@IdCostCenter]).Caption)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

jup
Level: Powered On

Re: Problem with SQL Query - Lookup funktion in Gallery (AddColumns)

Thanks so much my friend! 

You solved my problems 🙂

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 274 members 6,045 guests
Please welcome our newest community members: