cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kathryn-Marie
Regular Visitor

Lookup with multiple tabes

Hi,

 

I have a table for history, where old value can come from multiple tables. The item is stored in the history table as an ID, so I need to lookup multiple tables to find the description. I have tried this but the result I get is "false". Any ideas?

 

LookUp(Priorities, Priority_ID = ThisItem.'Old Value', Priority)
||
LookUp(Statuses, Status_ID = ThisItem.'Old Value', Status)
||
LookUp(Resources, Resource_ID = ThisItem.'Old Value', Name)
||
LookUp(Types, Type_ID = ThisItem.'Old Value', Type)
||
LookUp(Divisions, Division_ID = ThisItem.'Old Value', Division)
||
LookUp(Statuses, Status_ID = ThisItem.'Old Value', Status)

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Sorry for the late reply, I ended up with this result:

 

ClearCollect(Lookups, {
ID: "",
Value: ""
});

ForAll(Priorities,
Collect(Lookups, {
ID: Priority_ID,
Value: Priority
}));

ForAll(Statuses,
Collect(Lookups, {
ID: Status_ID,
Value: Status
}));

ForAll(Resources,
Collect(Lookups, {
ID: Resource_ID,
Value: Name
}));

ForAll(Types,
Collect(Lookups, {
ID: Type_ID,
Value: Type
}));

ForAll(Divisions,
Collect(Lookups, {
ID: Division_ID,
Value: Division
}));

ForAll(Statuses,
Collect(Lookups, {
ID: Status_ID,
Value: Status
}));

ForAll(Actions,
Collect(Lookups, {
ID: Action_ID,
Value: Action
}));

ForAll(Releases,
Collect(Lookups, {
ID: Release_ID,
Value: Release
}));

View solution in original post

3 REPLIES 3
poweractivate
Super User II
Super User II

@Kathryn-Marie 

 

You could try this:

 

1. Avoid || or && - here - those are boolean operators OR and AND, intended for conditions, and usually makes whole thing return true or false

 

2. Try AddColumns instead - 

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-table-shaping

 

AddColumns( Table, ColumnName1, Formula1 [, ColumnName2, Formula2, ... ] )

  • Table - Required. Table to operate on.
  • ColumnName(s) - Required. Name(s) of the column(s) to add. You must specify a string (for example, "Name" with double quotes included) for this argument.
  • Formula(s) - Required. Formula(s) to evaluate for each record. The result is added as the value of the corresponding new column. You can reference other columns of the table in this formula.

 

In your case

 

A. "Table" in your case should be an arbitrary variable or collection with a table in it.

and

B.  ColumnName, Formula - go through each and bring them in from multiple tables

 

Try above general approach to see if it works for you.

 

 

Also, see this for additional idea:

 

Syntax for joining tables 

v-siky-msft
Community Support
Community Support

@Kathryn-Marie,

 

|| (or) operator is only for boolean values. please try this:

If(
!IsBlank(LookUp(Priorities, Priority_ID = ThisItem.'Old Value', Priority)), LookUp(Priorities, Priority_ID = ThisItem.'Old Value', Priority), 
!IsBlank(LookUp(Statuses, Status_ID = ThisItem.'Old Value', Status)), LookUp(Statuses, Status_ID = ThisItem.'Old Value', Status),
...
)

 Sik

Sorry for the late reply, I ended up with this result:

 

ClearCollect(Lookups, {
ID: "",
Value: ""
});

ForAll(Priorities,
Collect(Lookups, {
ID: Priority_ID,
Value: Priority
}));

ForAll(Statuses,
Collect(Lookups, {
ID: Status_ID,
Value: Status
}));

ForAll(Resources,
Collect(Lookups, {
ID: Resource_ID,
Value: Name
}));

ForAll(Types,
Collect(Lookups, {
ID: Type_ID,
Value: Type
}));

ForAll(Divisions,
Collect(Lookups, {
ID: Division_ID,
Value: Division
}));

ForAll(Statuses,
Collect(Lookups, {
ID: Status_ID,
Value: Status
}));

ForAll(Actions,
Collect(Lookups, {
ID: Action_ID,
Value: Action
}));

ForAll(Releases,
Collect(Lookups, {
ID: Release_ID,
Value: Release
}));

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (64,049)