cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HCLin
Helper III
Helper III

First function not working but Last function works (The same situation)

Hi all,

 

I am curious about an issue I encountered.

 

I have a field in the contract table called "Funded", and this one is based on the "Total funding" in the latest modification record.

So I used the function to get the target item.

 

This function worked before, but somehow it always gives me an error and the text box became empty recently.

 

Text(First(Sort(ThisItem.OptionModifications,'Mod Date',Descending)).'Total Funding',"[$-en-US]$#,###.00")

 

 

First_1.png

 

Then I tried to change it to Last, then it works...

 

Text(Last(Sort(ThisItem.OptionModifications,'Mod Date',Ascending)).'Total Funding',"[$-en-US]$#,###.00")

 

This function will turn out a correct number, and will not show an error.

 

 

Those two functions basically are the same idea, just opposite direction approach, I still can't figure out why this happened...

 

Is there any idea ? 🤔

 

 

Thanks!

 

 

5 REPLIES 5
poweractivate
Super User
Super User

@HCLin Maybe the First record has something with the Total Funding field that cannot be processed by the rest of the formula. For example,  maybe that Record has blank value, or incorrect value, for that field. Check it and see if that's the reason.

I think here it is a problem of coincidence. If it happened to be the last record, Last would have given the same error.

Hi @poweractivate ,

 

Thanks for your reply!

 

It should not be the case, as you can see in the function, I used "Descending" to sort the items for "First", and used "Ascending" to sort the item for "Last", so basically they are the same item.

 

And I have also inputted the table to a gallery to check the items.

 

@HCLin Not sure why it is doing this.

 

Maybe try 

 

Text(Value(First(Sort(ThisItem.OptionModifications,'Mod Date',Descending)).'Total Funding'),"[$-en-US]$#,###.00")

 Doubt it would work just for that, but if for some reason it does, tell me.

Hi @poweractivate ,

 

I tried this before, and it would give me another error.

First_2.png

timl
Super User
Super User

@HCLin 

To diagnose this further, I would add a label and inspect the value of the following.

First(Sort(ThisItem.OptionModifications,'Mod Date',Descending)).'Total Funding'

I'd then compare it with the value that you get when you call Last.

Last(Sort(ThisItem.OptionModifications,'Mod Date',Ascending)).'Total Funding'

Can you see any differences in these 2 values without the call to Text?

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,366)