cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Skilled Sharer
Skilled Sharer

SQL - Multiple conditions, numerous versions of a record, modified date

Greetings,

 

I need to filter a sql dB utilizing multiple filter options where there are many ‘versions’ of a record. Based on the users filter selection(s) I want to bring back the most up-to-date record based on the ‘Modified Date’ column.  I’m thinking Max might work for this but could use some guidance on the formula so it applies to all possible selections.  This sql table has 239k records so I cannot collect them into my app. 5425B014-141E-48C9-ACAF-75EA180CB90D.png

3 REPLIES 3
Resolver III
Resolver III

Re: SQL - Multiple conditions, numerous versions of a record, modified date

I personally think this might be easier to do on the SQL side by using a view or Stored procedure rather than depending on PowerApps. 

 

Then use the view/stored proc to bring you the "latest" record you looking for.

 

This will help App performance.

 

Let me know if you need more information.

Highlighted
Community Support
Community Support

Re: SQL - Multiple conditions, numerous versions of a record, modified date

Hi @KickingApps ,

Could you please share a bit more about your scenario?

Do you want to display  most up-to-date records within the Data Table based on the "Modified Date" column?

 

Based on the needs that you mentioned, I think the combination of GroupBy function, AddColumns function and DropColumns function could achieve your needs.

I have made a test on my side, please take a try with the following workaround:

Add a Data Table control within your app, set the Items property of the Data Table to following:

DropColumns(
AddColumns(
GroupBy(
Filter(Datasource, RecordNbr = ddRecordNbr.Selected.Text || State = ddState.Selected.Text || Author = ddAuthor.Selected.Text),
"RecordNbr",
"GroupData"
),
"Author",
First(SortByColumns(GroupData, "Modified Date", Descending)).Author,
"State",
First(SortByColumns(GroupData, "Modified Date", Descending)).State,
"Modified Date",
First(SortByColumns(GroupData, "Modified Date", Descending)).'Modified Date'
),
"GroupData"
)

Then enable corresponding fields within the Data Table control, then the filtered records would be shown up.

 

Please take a try with above solution, then check if the issue is solved.

 

More details about the GroupBy function, AddColumns function and DropColumns function, please check the following article:

GroupBy function

AddColumns, DropColumns function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Anonymous
Not applicable

Re: SQL - Multiple conditions, numerous versions of a record, modified date

Hi @KickingApps how are you progressing with this?

 

@Anonymous 

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (3,466)