cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Applicable88
Advocate II
Advocate II

Display max time of a selected value from dropdown

Hello,

 

I have a dropdown menu from a datacard which for example can chose different task:

 

Task SubmitTime
Washing  04.08.2022 14:00:00
Washing  02.08.2022 11:00:00
Cleaning 04.08.2022 14:00:00
Cleaning 02.08.2022 19:00:00

 

I want to always filter the Max Time of a task chosen from a dropdown menu in a 

textfield

 

I tried this:

LookUp(Tasktable;Task = drpTask.SelectedText; Max(SubmitTime)

 

So for example when I chose "Washing" in the dropdown menu, I want a textlabel returns: "04.08.2022 14:00:00"

 

I always get an error, eventhough I 'm using all the recommended function from intellisense. 

 

Hope someone find my mistake. 

Best. 

1 ACCEPTED SOLUTION

Accepted Solutions

Hey, if you are only showing it on Text Label, then you will need to also select the property, like this:

First(
SortByColumns(
Filter(
Tasktable,
Task = drpTask.Selected.Task
),
"SubmitTime", Descending
)
).SubmitTime

View solution in original post

7 REPLIES 7
metsshan
Solution Sage
Solution Sage

Using an aggregate function like Max() as a standalone expression is not supported in LookUp() or Filter(), because it is not making a comparison - the expression(s) need to return TRUE or FALSE.

 

You probably don't want to be using Dropdown.SelectedText, rather you want to reference a property of the Dropdown.Selected.

 

If you just need to know the maximum, then you can probably use the Max(DataSource, Expression) function, but if you need the Record, then you might try the following (untested).

First(
SortByColumns(
Filter(
Tasktable,
Task = drpTask.Selected.Task
),
"SubmitTime", Descending
)
)

 

Applicable88
Advocate II
Advocate II

Hello @metsshan , thank you so far. But this also doesn't work. Why is "SubmitTime" in quotation marks?

I tried either way, I somehow think the drpTask.Selected.Task is the problem. 

 

Hope you know a solution.

Best. 

 

 

 

Hi, some functions like SortByColumns reference the name of the column as a string of text eg:

SortByColumns(People, "Created", Descending)

 

What is the error you are getting?

Hey, if you are only showing it on Text Label, then you will need to also select the property, like this:

First(
SortByColumns(
Filter(
Tasktable,
Task = drpTask.Selected.Task
),
"SubmitTime", Descending
)
).SubmitTime

@metsshan , I'm still getting this error:

Some types are incompatible for comparison. These types cannot be compared: Text, Error...

Can you please share with me what the "Tasktable" data source looks like?

 

Can you please share the Items property of the dropdown?

 

Thanks

@metsshan I just found my mistake! I made a typical mistake that I used special characters for the column name, but when I first load the SP List the system automatically changed the special characters. I saw this just now when looking in the SubmitTime column's Datafield. 

 

Thank you very much !

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,881)