web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Syntax for joining tables
Power Apps
Answered

Syntax for joining tables

(12) ShareShare
ReportReport
Posted on by Microsoft Employee

I am having a heck of a time trying to understand the syntax of powerapps.

 

I have a background in SQL and I am very comfortable with it. This is not SQL :(.

 

I have an SQL database. My SQL database was built correctly, with the min amount of repeating data. It seems like Powerapps wants me to have 1 giant table with everything on it instead of multiple tables that are related and joined.

 

Here is what I need to understand:

 

Example - I have 3 tables with information I need from each in a gallery.

 

Table 1 - UPC_Details

Columns (UID) UPC_ID, Brand_ID, Cost, Created_Date

 

Table 2 - Brand_ID

Coulmns (need to join to UPC_Details Brand_ID) (UID) Brand_ID, Brand_Name, Company_Contact_ID...

 

Table 3 - UPC_received

Columns (UID) UPC_Received_ID, (need to join to table UPC_Details so users know what item they are looking at when the UPC is scanned) UPC_ID, Cases_received, Date_received...

 

 

I am sure you can see where this is going.

I need my users to be able to see specific data that I normally would use a join to reference. I do not know if I should be building a collection onvisble, or something else entire. Nor do I undertand the syntax Powerapps uses. I am extremely dissapointed with the resources for Powerapps, as I do not feel these questions are well answered and I am sure I am not the only user with this problem.

 

Thank you in advance to anyone willing to help me out with this.

Categories:
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    You can use the functions AddColumns and LookUp to perform joins in PowerApps. Taking the example from W3Schools, where we have two tables:

    Orders

    OrderID CustomerID OrderDate
    10308 2 1996-09-18
    10309 37 1996-09-19
    10310 77 1996-09-20

    Customers

    CustomerID CustomerName ContactName Country
    1 Alfreds Futterkiste	 Maria Anders Germany
    2 Ana Trujillo Emparedados Ana Trujillo Mexico
    3 Antonio Moreno Taquería Antonio Moreno Mexico

    To generate the result of the JOIN listed in that page:

    SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
    FROM Orders
    INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID

    This would be a similar expression in PowerApps:

     

    ShowColumns(
     AddColumns(
     Orders,
     "CustomerName",
     LookUp(Customers, CustomerId = Orders[@CustomerId], CustomerName)),
     "OrderId", "CustomerName", "OrderDate")

    You can also join the entire customer record, instead of only choosing a single column from that table. For example, if you have this expression in a button's OnSelect property:

    ClearCollect(myCollection,
     AddColumns(
     Orders,
     "Customer",
     LookUp(Customers, CustomerId = Orders[@CustomerId])))

    Then you can access the name of customer for the first order using:

    First(myCollection).Customer.CustomerName

    Or if you set the 'myCollection' to the Items property of a gallery, you can have a label within the gallery with the Text property set to

    ThisItem.Customer.CustomerName

    And it would show the customer name for that row in the (augmented) orders table.

     

    Granted, I agree that a SQL join with all other niceties (grouping, native filtering, etc.) would be nice to have. There is an existing idea to support SQL queries (instead of simple tables) directly in the PowerApps Ideas board, please consider voting on it!

  • Meneghino Profile Picture
    6,949 on at

    Hi @Mickell2030

    Fully sympathise, it takes a few days to understand how PowerApps works, but then it will all be clear.

    @CarlosFigueirais right in using LookUp, and another key to joining tables is the 'in' operator.

    Please see this post of mine for example, just ignore the intro and go to the PowerApps expressions:

    https://baizini-it.com/blog/index.php/2017/10/10/powerapps-101-many-to-many-relationships-between-tables/

    Other posts on my blog may also be of help, for examplein improving performance of lookups.

    Comments/questions welcome.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    thank you. You took the time to really detail it out and I get it. I want to love Powerapps because so many other things are simpler from a programming prospective. I sure do hope this will become a bit cleaner with time and that SQL can become integrated language. Until then, your explanation was the best I could have hoped for.

  • Delid4ve Profile Picture
    795 on at
    The nightmare starts when you need to use the 'in' operator and join 3 tables on many to many relationships. I do have solutions if you get really stuck.
  • MigChatter Profile Picture
    6 on at

    Hi

     

     

     

     

     

     

  • Delid4ve Profile Picture
    795 on at

    Collect(List1Collection,AddColumns(List1,"Group",First(Filter(List2,SalesPerson=SalesPerson)).Group)

    This will put it into a collection.

    Havnt tested but you may need to use @ before 2nd salesperson or List1.SalesPerson, im not on the system at present and its been a while.

     

    if you want to do it live within a gallery for instance you can set the gallery items to List1, then have a text box that just does: First(Filter(List2,SalesPerson=ThisItem.SalesPerson)).Group within each gallery item

     

    I find First(Filter)) works faster than Lookup() but you can also use: Lookup(List2,SalesPerson=ThisItem.SalesPerson,Group)

     

     

  • MigChatter Profile Picture
    6 on at

    Thank you for the response.

    I tried with the above but still i have no luck.

     

  • AlesonITC Profile Picture
    49 on at

    Hi all.

     

    I've got 2 joined tables with that syntax:

     

    ShowColumns(AddColumns('[SIE].[DatosGenerales]';"Denominacion";LookUp('[Dim].[DimSIE]'; DimSIEId = '[SIE].[DatosGenerales]'[@DimSIEId]; Denominacion));"Denominacion";"DimSIEId";"ModificadosMesActual";"PresupuestoInicialMesActual";"TrabajosATercerosMesActual";"RevisionDePreciosMesActual";"ComplementariosMesActual";"OtrosMesActual";"PresupuestoVigenteMesActual";"Mes")

     

    It's just a table SIE.DatosGenerales and the column "Denominacion from DIM.DimSIE,but I want tomake a "Where" there to show only the rows I want. How can I do it?

     

    Hope it can helps you.

  • marcoselias Profile Picture
    22 on at

    LookUp only returns the first record that is matched. What if there are multiple records to match? I'm guessing a Filter would do the trick. Is that right or is there a more efficient way?

  • Delid4ve Profile Picture
    795 on at
    I hardly ever use lookup.
    First(Filter(Table,Expression)).Column
    Or
    Last(Filter(Table,Expression)).Column
    You can also add a sortbycolumns in there if you want say the first date column etc
    It’s faster than lookup aswell

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard