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 / AddColumns is not work...
Power Apps
Unanswered

AddColumns is not working for Lookup columns

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

We have 3 entities in Dynamics 365:
1. Contact
2. Screen Criteria
3. Progress Data

Progress Data is the child of Contact and Screen Criteria entities i.e. Progress Data has lookups of Contact and Screen Criteria.
For the given Contact record, we are fetching all the related Progress Data records as follows:
ClearCollect(tblTempProgressData,
       Filter('Progress Data',
                ThisRecord.Contact.lna_contactid = GUID(varContactID)
       )
);

This works good and loads all the related Progress Data records in tblTempProgressData collection. Now I want to add two columns named "Screen Name" and "Screen Order" with the data from related entity records Screen Criteria into the each rows of collection tblTempProgressData and I have written following lines of code:
ClearCollect(tblProgressData,
         AddColumns(
                tblTempProgressData,
                "Screen Name",
                LookUp(
                       'Screen Criteria',
                       'Screen Criteria' = tblTempProgressData[@'Criteria'].'Screen Criteria',
                       'Screen Name'
                ),
                "Screen Order",
                LookUp(
                      'Screen Criteria',
                      'Screen Criteria' = tblTempProgressData[@'Criteria'].'Screen Criteria',
                      'Screen Order'
               )
        )

);

Criteria is the lookup name of Screen Criteria entity in Progress Data entity.

This code doesn't seem to be working as "Screen Name" and "Screen Order" columns in tblProgressData has no values. It would be very helpful if some one could let me know what's wrong here and what is the correct way of doing this?

 

Thanks

Categories:
  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    Is 'Screen Criteria' the name of both the data source and a column in the data source? 

    If so, have you tried something like this in the lookup formula

    'Screen Criteria'[@'Screen Criteria'] = tblTempProgressData[@'Criteria'].'Screen Criteria'

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @Jeff_Thorpe for the quick reply.

     

    After doing a lot of experiments, I found that my code as well as what you have suggested, both works but there is a catch. In order to make the code work, I will have to bind the collection tblTempProgressData with a data table.

    When I bind the collection tblTempProgressData with a data table to show the data on screen then only "Screen Criteria" field in tblTempProgressData collection holds the data but if I don't bind the collection with the data table then "Screen Criteria" field holds blank values and the condition 'Screen Criteria' = tblTempProgressData[@'Criteria'].'Screen Criteria' fails.

    Is there any setting which prevents the collection to load with the data from CDS unless it is being used?

     

    Thanks

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard