Distinct function - Power Platform (2024)

Applies to: Distinct function - Power Platform (1) Canvas apps Distinct function - Power Platform (2) Desktop flows Distinct function - Power Platform (3) Model-driven apps Distinct function - Power Platform (4) Power Platform CLI

Summarizes records of a table, removing duplicates.

Description

The Distinct function evaluates a formula across each record of a table and returns a one-column table of the results with duplicate values removed. The name of the column is Value.

Fields of the record currently being processed are available within the formula. Use the ThisRecord operator or simply reference fields by name as you would any other value. The As operator can also be used to name the record being processed which can help make your formula easier to understand and make nested records accessible. For more information, see the examples below and working with record scope.

When used with a data source, this function can't be delegated. Only the first portion of the data source will be retrieved and then the function applied. The result may not represent the complete story. A warning may appear at authoring time to remind you of this limitation and to suggest switching to delegable alternatives where possible. For more information, see the delegation overview.

Syntax

Distinct( Table, Formula )

  • Table - Required. Table to evaluate across.
  • Formula - Required. Formula to evaluate for each record.

Example

  1. Insert a Button control, and set its OnSelect property to this formula.

    ClearCollect( CityPopulations, { City: "London", Country: "United Kingdom", Population: 8615000 }, { City: "Berlin", Country: "Germany", Population: 3562000 }, { City: "Madrid", Country: "Spain", Population: 3165000 }, { City: "Hamburg", Country: "Germany", Population: 1760000 }, { City: "Barcelona", Country: "Spain", Population: 1602000 }, { City: "Munich", Country: "Germany", Population: 1494000 });
  2. Select the button while holding down the Alt key.

    The formula is evaluated and the CityPopulations collection is created which you can show by selecting CityPopulations in the formula bar:

    Distinct function - Power Platform (5)

  3. Insert a Data table control, and set its Items property to this formula:

    Distinct( CityPopulations, Country )

    You can view the result of this formula in the formula bar by selecting the entire formula:

    Distinct function - Power Platform (6)

  4. Use the Edit fields link in the data table's properties pane to add the Value column:

    Distinct function - Power Platform (7)

  5. Insert a Label control, and set its Text property to the formula:

    First( Sort( Distinct( CityPopulations, Country ), Value ) ).Value

    This formula sorts the results from Distinct with the Sort function, takes the first record from the resulting table with the First function, and extracts the Result field to obtain just the country/region name.

    Distinct function - Power Platform (8)

Feedback

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.

Submit and view feedback for

Distinct function - Power Platform (2024)
Top Articles
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 5713

Rating: 4.3 / 5 (64 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.