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 / Inner Join three table...
Power Apps
Answered

Inner Join three tables to show records

(0) ShareShare
ReportReport
Posted on by 641

Hello,

 

I want to get records in collection(gallery) to view by Site.

 

The values/contents of my tables are specified Sites and there User with application they belong.

Table1(Site Details with User) having 3 columns which have following data:-

 

SiteIDUserIDApplication
001User0011
001User0012
001User0021
001User0022
002User0011
002User0032
003User0032
003User0042

 

 

Table2 - 'Site Details' having SiteID and Name, such as:-

Site IDSite Name
001Site1
002Site2
003Site3

 

 

Table 3 - 'User Role Table' -having records UserID and Role and Application

UserIDRoleApplication
User001Submitter1
User001Engineer2
User002First Approver1
User002Second Approver1
User003Initiator2
User004Area Approver2

 

* any user can have multiple access on same/different applications.

Table 4- User Role Details- having Role name and application

 

Role NameApplication
Submitter1
First Approver1
Second Approver1
Engineer2
Initiator2
Area Approver2

 

Now, my end result what I want is-

Site CodeSite NameUser NameUser RoleApplication
001Site 1User001Submitter1
001Site 1User001Engineer2
001Site 1User002First Approver1
001Site 1User002Second Approver1
002Site 2User001Submitter1
002Site 2User003Initiator2

 

My issue here is that, how can I get User Role as that was not directly associated with Site table.

 

Please let me know if any other information needed.

 

@ericonline @WarrenBelz @RandyHayes 

 

Thanks,

 

Categories:
  • panand99 Profile Picture
    641 on at

     

    This SQL query can get the data which want

    Select mua.USER_ID, usm.SITE_ID, usm.APP_ID, urm.ROLE_ID into #temp from [dbo].[MSTR_USER_A] mua
    left join USER_SITE_MAP_A usm on mua.USER_ID = usm.USER_ID
    left join USER_ROLE_MAP_A urm on urm.USER_ID = mua.USER_ID and usm.APP_ID = urm.APP_ID

    Select temp.USER_ID, temp.SITE_ID, isNull(temp.APP_ID, urm.APP_ID) as APP_ID, isNull(temp.ROLE_ID, urm.ROLE_ID) as ROLE_ID from #temp temp
    left join USER_ROLE_MAP_A urm on temp.User_Id = urm.USER_ID and temp.ROLE_ID is null

    drop table #temp


    Can anyone please let me know how to convert it into powerapps function?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I would recommend creating a VIEW at the SQL server, then pulling the VIEW into PowerApps. This is MUCH easier than translating that TSQL to PowerApps language.

  • panand99 Profile Picture
    641 on at

    Thanks for your reply Eric, but this is currently not possible to create new TABLE in CDS.

     

    that query is for refrence purpose only which we write in our local sql environment.

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @panand99 

    Sorry for delay...trying to catch up on all the posts.  Are you still experiencing issues that you need help with?

  • Verified answer
    panand99 Profile Picture
    641 on at

    Thank you very much @RandyHayes for your support. Actully, I figured it out this issue by creating multiple loops/conditions in html text field.

  • pursuit Profile Picture
    2 on at

    Hi , how did you solve this issue?

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 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard