cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
FinePilsner
Level: Powered On

First in Data Table control doesn't update properly

Hi all

Running into some strange behavior when using the First or FirstN functions in PowerApps.

I have a data table control in the PowerApp that shows a filtered and sorted data source. The filtering is based on a variable (we'll call it var_Item_Num) that the user enters. The formula looks like this:

=SortByColumns(Filter(My_Data_Source,Item_Number_Column = var_Item_Num), "Date_Time",Descending)

Works fine -- as soon as the user changes var_Item_Num, the data table updates. If the var_Item_Num is not found within the source, the data table is blank/empty. Great.

Next I wanted to only return the first/most recent resuly from this filtered source instead. This is where I'm running into issues. Tried with both First/FirstN like so:

=First(SortByColumns(Filter(My_Data_Source,Item_Number_Column = var_Item_Num), "Date_Time",Descending))

This is fine if var_Item_Num is found -- the most recent result is returned. However the behavior changes when var_Item_Num is not found; instead of showing blank, the data table just doesn't update. It shows whatever the previous result was. For example if I search 1111 and view the first result, then search 2222 which is not in the data source, the result for 1111 is still shown.

If I remove First, this behavior is corrected immediately -- a search for 1111 and then 2222 will yield an empty data table as expected.

Why is this happening?

2 REPLIES 2
Super User
Super User

Re: First in Data Table control doesn't update properly

Hi @FinePilsner 

Just for a test could you try and see if this works

Lookup(Sort(My_Data_Source, Date_Time, Descending),Item_Number_Column = var_Item_Num)
FinePilsner
Level: Powered On

Re: First in Data Table control doesn't update properly

Thanks for the reply -- Just tried this, exact same issue. Searching for a record that has no results fails to clear/empty the data table, and the result from the previous (successful) lookup remains.

 

I ended up just creating a text label with multiple SORT/LOOKUPS rather than using a data table. There's some fundamental bug here in Data Tables that needs to be addressed -- when their data source changes to have no items, they don't appear to clear out.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 278 members 5,161 guests
Please welcome our newest community members: