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 / LastN and Last Conditi...
Power Apps
Answered

LastN and Last Conditional Formatting Combobox table & Record Issues

(0) ShareShare
ReportReport
Posted on by 174

Hi,

 

I have an app that patches a bunch of comboboxes into sharepoint, there is a slight difference to this app and the "normal" way of just straight patching and that is the actual row data vs displayed value. For example the values displayed in the comboboxes are words but the patch sends code to the database and displayed in a gallery ie the word "Normal" would be displayed in the combobox but patched to the database and displayed in a gallery as  "NM" for example

 

The comboboxes values are made from a table that runs on start, which looks like the following example

 

 

ClearCollect(
 colExample,
 {
 Id: 0,
 CODE: "",
 Word: ""
 },
 {
 Id: 1,
 CODE: "NM",
 Word: "Normal"
 },

 

 

 

There is also various modes which change the comboboxes value depending on what the user is doing, ie varMode = "New" would display blank values, varMode = "Edit" would be a Lookup to display the gallery selected item in words and varMode = "Continue" or "Final" would be a Lookup to display the galleries last entered data. (Its preempting the values the user will most likely use, but they can change if necessary, 99% of the time its the same value) Getting the last entered data to display does not work when i use LastN or Last, ie.

 

 

 

If(
 varMode = "New" && IsEmpty(GeologySelectGallery.AllItems),
 LookUp(
 colGeologyMoist,
 MCODE = ""),
 varMode = "Edit",
 LookUp(
 colGeologyMoist,
 MCODE = GeologySelectGallery.Selected.MOIST
 ),
 varMode = "Continue" && NextSampleID_1.Text = "RZ000001",
 LookUp(
 colGeologyMoist,
 MCODE = ""),
 varMode = "Continue" || varMode = "Final",
 LookUp(
 colGeologyMoist,
 MCODE = LastN(GeologySelectGallery.Selected.MOIST))

)

 

 

Error msg is "The function LastN has some invalid arguments"

or

 

 

If(
 varMode = "New" && IsEmpty(GeologySelectGallery.AllItems),
 LookUp(
 colGeologyMoist,
 MCODE = ""),
 varMode = "Edit",
 LookUp(
 colGeologyMoist,
 MCODE = GeologySelectGallery.Selected.MOIST
 ),
 varMode = "Continue" && NextSampleID_1.Text = "RZ000001",
 LookUp(
 colGeologyMoist,
 MCODE = ""),
 varMode = "Continue" || varMode = "Final",
 LookUp(
 colGeologyMoist,
 MCODE = Last(GeologySelectGallery.Selected).MOIST)

)

 

 

Error msg is "Invalid argument type (Table). Expecting a record value."

 

Could someone shed some light on how to display the last record value for the variable?

 

 

Categories:
  • Verified answer
    SomeoneAwesome Profile Picture
    174 on at

    Argh so simple, im a mong.

     

    Last(Gallery.AllItems).ColumnName)

  • Verified answer
    WarrenBelz Profile Picture
    156,774 Most Valuable Professional on at

    Hi @SomeoneAwesome ,

    What exactly is MOIST in the gallery - if you are looking for the field MOIST in the last item in the Gallery, it would be

    Last(GeologySelectGallery.AllItems).MOIST

    If this is a Multi-choice field in the gallery, it would be

    Last(GeologySelectGallery.Selected.MOIST).Value

     

    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.

    Visit my blog Practical Power Apps

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard