Skip to main content

How to Get the Largest Value in Power Apps with Max

· 3 min read
Jagdish Kumawat
Founder @ Dewiride

Max returns the largest of its numbers. Give it a list of values, or a table and a column, and it hands back the biggest. Beyond the obvious uses, like the latest score or the highest amount, it's handy for layouts: "make this as tall as whichever of these is tallest".

Syntax​

Syntax
Max( Number1 [, Number2, ... ] )
Max( Table, NumericalFormula )

Microsoft's aggregate functions reference notes that these functions operate on numbers only; other types, such as text, are ignored. Min works the same way for the smallest value.

Prerequisites​

  • A canvas app with a Text control to try formulas in. The example is the Career Development Plan app, from Part 4 of the series.

Step 1: The Largest of Two Numbers​

Text control → Text
Max(72, 114)

The formula bar with Max(72, 114), the preview strip reading 114 with Data type number

Step 2: Use It for a Layout​

In the example, a profile row holds a 72-pixel avatar next to three lines of text that can wrap on a phone. The row has to be as tall as whichever is taller:

conProfileHS → Height
Max(
avtMeHS.Height,
lblWelcomeHS.Height + lblJobTitleHS.Height + lblManagerHS.Height + 2 * conProfileTextHS.LayoutGap
)

On a wide screen the text needs 114 pixels, so the row is 114. On a phone the text wraps, the Text controls grow (their Auto height is on), and the row grows with them. Fixed: Text Is Cut Off Inside a Container on Small Screens in Power Apps explains why this was needed.

Step 3: The Largest Value in a Table​

With a table and a column:

Example
Max( Sales, CostPerUnit * UnitsSold )

The formula is worked out for each row, and the largest result returned. With a data source such as SharePoint, check whether Max can be delegated, or it only sees the rows downloaded.

Common Mistakes​

MistakeWhat happensDo this instead
Passing text numbers, such as "5"Text is ignoredConvert with Value first
Using Max on a big list without checking delegationOnly downloaded rows are consideredCheck the delegation warning
Expecting the row backMax returns the number, not the recordUse Sort and First to get the row

FAQ​

What about the smallest value?​

Min, with the same syntax.

Can Max compare dates?​

Microsoft describes these functions as numeric. For dates, sort the table instead and take the first row.

What if every value is blank?​

There's nothing numeric to compare. Guard the inputs with Coalesce if blanks are possible.

Conclusion​

Max(a, b, …) or Max(table, formula) returns the largest number. In layouts, it's a neat way to size a container to its tallest content.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.