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 / SortBy column for look...
Power Apps
Answered

SortBy column for lookup field

(0) ShareShare
ReportReport
Posted on by 375

Hi I have a table with SortBy columns formula. One of the field,"crc82_ItemIDprodmaster" contains delegation warning. It is a lookup field. The data for that lookup field isn't shown inside the table. How to solve this? 

 

lookup delegation warning.PNG

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at

    Hi @NurNina ,

    I did a bit of testing here and confirmed that you cannot Sort by a Lookup column. Will this work for you?

    Sort(
     ShowColumns(
     Filter(
     'Sales Order Lines', 
     ’Sales Id' = SalesOrderlD
     ),
     "crc82_itemid",
     "crc82_ItemIDprodmaster", 
     "crc82_inventoryuom",
     "crc82_salesprice”,
     "crc82_salesqty",
     "crc82_discount"
     ),
     "crc82_lineamountnew",
     Ascending
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

     

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @NurNina 

     

    Can you try out the below formula to directly filter on a LookUp field:
     
    SortByColumns(AddColumns(Filter('Sales Order Lines', ’Sales Id' = SalesOrderlD),"LookUpColText",crc82_ItemIDprodmaster.ColumnToFetch),"crc82_itemid",LookUpColText, "crc82_inventoryuom","crc82_salesprice”,"crc82_salesqty","crc82_discount","crc82_lineamountnew",Ascending)
     
    Hope this Helps!

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
  • WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at

    @NurNina ,

    @yashag2255 's solution is more suited to your needs than mine (and a very nice way of changing column spec with AddColumns - I have made a note of it).

    Parsed below - please accept his solution if this works for you.

    SortByColumns(
     AddColumns(
     Filter(
     'Sales Order Lines', 
     ’Sales Id' = SalesOrderlD
     ),
     "LookUpColText",
     crc82_ItemIDprodmaster.ColumnToFetch
     ),
     "crc82_itemid",
     LookUpColText, 
     "crc82_inventoryuom",
     "crc82_salesprice”,
     "crc82_salesqty",
     "crc82_discount",
     "crc82_lineamountnew",
     Ascending
    )

     

  • NurNina Profile Picture
    375 on at

    @yashag2255 I have tested this formula but Im not sure what could be the problem because the data in the lookup field is still not shown in the table. 


    latest snip.PNG

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @NurNina ,

    Firstly, based on the SortByColumns formula that you mentioned, I think there is something wrong with it. The syntax of SortByColumns function as below:

    SortByColumns(Table, ColumnName1 [, SortOrder1, ColumnName2, SortOrder2, ... ] )

     

    Then the"crc82_ItemIDprodmaster" field is a LookUp type field, which is essentially a Record value. You could not specify complex type column as Sort columns within the SortByColumns function.

     

    As an fixed solution, please consider modify your formula as below:

    Sort(
     SortByColumns(
     Filter('Sales Oder Lines', 'Sales Id' = SalesOrderID),
     "crc82_itemid", Ascending,
     "crc82_inventoryuom", Ascending,
     "crc82_salesprice", Ascending,
     "crc82_salesqty", Ascending,
     "crc82_discount", Ascending,
     "crc82_lineamountnew", Ascending
     ),
     ItemIDprodmaster.'Primary Name',
     Ascending
    )

    Note: The 'Primary Name' represents the field in your CDS Entity which the crc82_ItemIDprodmaster" LookUp field references values from. Please replace it with actual field name from your referenced Entity.

     

    Best regards,

  • NurNina Profile Picture
    375 on at

    @v-xida-msft hi, thank you. I have tested the formula but data for the lookup field is still not showing inside the table.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @NurNina ,

    Do you want the LookUp field value to be displayed within the Data Table control?

     

    If you want to display the LookUp field value within the Data Table, please select the LookUp column within the Data Table, then set the Text property of the column to following:

    ThisItem.ItemIDprodmaster.'Primary Name'

    Note: The ItemIDprodmaster represents the LookUp field in your CDS Entity

    7.JPG

     

    If you want to display the LookUp field value within a Gallery, same formula logic should be applied to the Label inside the Gallery.

     

    Best regards,

  • NurNina Profile Picture
    375 on at

    @v-xida-msft im not sure why but my table version, the column doesnt have any Text property.

     

    column.PNG

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @NurNina ,

    Have you enabled "Enable improved data table control selection and Value property" option within Advanced settings of your App settings of your app?

     

    Please consider turn on the "Enable improved data table control selection and Value property" option within Advanced settings of your App settings of your app, then re-insert a new Data Table in your app screen, then try above solution I provided again, check if the issue is solved.

    8.JPG

     

     

    Best regards,

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard