Showing results for 
Search instead for 
Did you mean: 

Getting a date, task, and name from a table.

I tried figuring this out in Excel, but to no avail. At my work, we have a series of tasks that have to be done every 90 days. The date that a task is completed is being saved to a database in SQL. Within PowerApps, I want to create a screen that shows when an employe's next date to complete a task (numbered Task 1-5) and how many they have done it throughout the year.   When an employee completes a task, he or she will have 90 days to complete it again.  I know to add dates, I would use the following formula.  





Here's the table:

EarnDate Id TaskEmployee
9/1/20171234Task1 Bob



I'm applying this formula to a Text Label under the Text attribute. The part I'm having difficulties with is pulling the correct date, task and person from the table. Now, would that be done by doing this? This is a simliar formula from an earlier post based on getting an inventory number.


DateValue( Mid( First( Sort( Filter(database1, StartsWith(Task1, PersonDropdown.Selected.Value)), Task1, Descending)).Task1 Len(TextInput1.Text) + 90 )

 Is this close?







Super User
Super User

Re: Getting a date, task, and name from a table.

Let me ask a few things first: do all the employees have an account so they can use PowerApps? Will they be allowed to see tasks belonging to someone else?


If they have an account but are allowed to see only their own tasks you can use User().FullName function to filter, IF their full name is saved in the SQL db.


If all of that is true I would put the data in a gallery, and also add an extra label with the future date. If the EarnData is older than 90 days, do not display anything, otherwise display the date 90 days after.


The label's Text would look something like this:


If(DateAdd(ThisItem.EarnDate, 90) > Now(), DateAdd(ThisItem.EarnDate, 90), "")

The gallery's Items property would look something like:


SortByColumns(Filter(database1, Employee = User().FullName), "Task", "EarnDate", SortOrder.Descending)

Try it out and give a shout back if you need more info. I haven't tried any of this specific code in an actual app, so there might be a few typos in there.


Good luck!


Re: Getting a date, task, and name from a table.



All the employees have access to Power Apps.  It's not an issue if an employee sees another's data. This information was originally on a Google spreadsheet and a report was in a different sheet all together. What makes the task a bit more difficult is that the original script to calculate the dates was in the now depricated Google Script.


In the old report wouild show when the expiration date was going to occur. It was formatted like this :


name	  task1	          task2 	 task3	          task4
bob	1/2/2018	12/30/2017	11/23/2017	12/31/2018


Using the gallery as a starting part works so far, as does your suggested formulas.  The next step for me is to create a chart using Text Labels.  However I have concerns about having 10 different galleries (as there are 10 different tasks/certifications per employee)  on one screen sending a call to the database at once. Could cause performance issues. Thank you for your help so far. 






Super User
Super User

Re: Getting a date, task, and name from a table.


What about putting the user names in a listbox, using a call to Distinct or hard coding them, and then you filter the data in the gallery based on the selected user? That way you would get a list over the different tasks per user. You can make the gallery horizontal so it looks very similar to your old report.


If the task names are static you can just make a panel with labels. In each label you make a call with Lookup to get the date for the specific task for the selected user. That way you don't have to use a gallery.


Another approach is to put the task names in a separate table and then you can create a gallery by combining a user and a task. That way both the names of the tasks and the number of tasks can change over time.


If you think a particular approach is interesting but unclear, get back and I'll try to make it clearer.


If you can and want, post a screen shot of what you have, or maybe a mockup of what you want so we can have something more visible to talk about.


 Good luck!

Re: Getting a date, task, and name from a table.


My current plan is as follows:


1. Create a panel with labels  of all the required tasks and dates. (done)

2. Use a drop down filter to change the values of the labels when a user is selected. 


I think applying the Filter or Lookup function to the labels could be a good course of action. Under the Total section, I would use the COUNTROWS function that would add the number of times a task has occured over the past 90 days. 


As for the date function, I know that I can use the LOOKUP function to search for the log to find the correct task in the table. Then use DATEADD function to add 90 days to find the date of expiration. 


Here's a current screenshot:Capture.PNG








Re: Getting a date, task, and name from a table.

I think I'm getting close , but I've ran into another metaphorical brick wall. I think the issue might be due to my Db design, but here's my problem. 


When I use the LOOKUP function, it simply returns the first record. I know that the LOOKUP function is designed to search a table and return a single value from a record.  When using it, is there a way to get the last record from the table? And, am I able to use LOOKUP to search multiple columns?


For example


DateAdd(LookUp('[dbo].[CmStats]', Cm2HoistType1 || Cm2HoistType2 || Cm2HoistType3 = "Insert" ,StartDate), 90,Days) 




Not applicable

Re: Getting a date, task, and name from a table.

Hi @BrendonBrooksP1


To access last item form data source you can use Last() function.




LookUp does not only provide value of one column, but can also return a whole record if the column is not specified.


Yes you can search multiple columns in a LookUp. For example your condition should be written like this:


DateAdd(LookUp('[dbo].[CmStats]', (Cm2HoistType1 = "Insert") || (Cm2HoistType2 = "Insert") || (Cm2HoistType3 = "Insert"),StartDate), 90,Days) 


Re: Getting a date, task, and name from a table.



Thanks for the formatting correction! Your answer definately points me in the right direction. 

Helpful resources


Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.


Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Power Platform World Tour

Coming to a city near you


PowerApps Community User Group Member Badge

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


Join PowerApps User Group!!

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

Top Kudoed Authors
Users Online
Currently online: 194 members 5,204 guests
Please welcome our newest community members: