cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Manarjomar
Resolver I
Resolver I

Get the Max value with filter or condition

Hi there,

 

I'm trying to build a "serial numer", but need a conditional, until today I did it using "CountRows(Filter(", but I have the problem with non delegable formulas.

 

So I think maybe is possible do it with Max funtion, but I don't know how I can do it.

 

My alternative code that I'm trying is:

 

 

Max(Filter('[dbo].[tbPO]';IdProject = proyecto).Line)+1

 

 

If not possible, How I can do it to avoid the issues with non delegable functions?

 

Thank you.

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

@Manarjomar 

I missed the FIRST function.  Include this:

 

Sort(First(Filter('[dbo].[tbPO]';IdProject = proyecto),Line, Descending)).Line+1


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Thank you @mdevaney your formula doen't work, but I understood your idea and I found that only was an order error. Finally works with this one:

 

If(FormPO.Mode = FormMode.New ; First(Sort(Filter('[dbo].[tbPO]';IdProject = proyecto);Line; Descending)).Line+1;DataTablePO.Selected.Line)

 

Thank you for your help.

 

Regards.

 

 

View solution in original post

5 REPLIES 5
mdevaney
Super User III
Super User III

@Manarjomar 
MAX cannot be delegated: so just use a Sort function instead.  It does the same thing.

Sort(Filter('[dbo].[tbPO]';IdProject = proyecto),Line, Descending).Line+1

 

Note: I assume 'Line' is a number type.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

eka24
Super User III
Super User III

Try:

Max('[dbo].[tbPO]';IdProject)+1

Max(Datasource,Column)+1

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

Hi@mdevaney ,

 

Yes, you are right, "Line" is a number, but the function doesn't work:

 

Screenshot_1.pngScreenshot_2.png

 

My last function was:

 

Screenshot_3.png

 

Regards.

@Manarjomar 

I missed the FIRST function.  Include this:

 

Sort(First(Filter('[dbo].[tbPO]';IdProject = proyecto),Line, Descending)).Line+1


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Thank you @mdevaney your formula doen't work, but I understood your idea and I found that only was an order error. Finally works with this one:

 

If(FormPO.Mode = FormMode.New ; First(Sort(Filter('[dbo].[tbPO]';IdProject = proyecto);Line; Descending)).Line+1;DataTablePO.Selected.Line)

 

Thank you for your help.

 

Regards.

 

 

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,189)