Power Apps  

Use Concat() Function In Power Apps

Power Apps is a powerful platform that allows you to build apps quickly without deep coding knowledge. One of the most commonly used functions in Power Apps is Concat(), which helps you combine multiple values from a table into a single text string. In this article, we’ll explore Concat() in detail with examples.

What is Concat() in Power Apps?

The Concat() function in Power Apps is used to:

  • Combine text values from a table.

  • Apply formatting or separators between values.

  • Return a single text string as a result.

Syntax:

Concat(Table, Formula, Separator)
  • Table: The table or collection containing the data you want to combine.

  • Formula: The column or expression you want to concatenate.

  • Separator (optional): A string to insert between concatenated values, e.g., comma, space, or semicolon.

Step 1: Create a Sample Table

Before using Concat(), we need a data source. You can create a collection in Power Apps for testing.

  1. Open your Power Apps Studio.

  2. Create a blank canvas app.

  3. Go to the OnStart property of the App and enter the following formula:

ClearCollect(
    colFruits,
    {Name: "Apple"},
    {Name: "Banana"},
    {Name: "Mango"}
);

ClearCollect(
    colCars,
    {Name: "BMW"},
    {Name: "Audi"},
    {Name: "Tesla"}
);

ClearCollect(
    colAnimals,
    {Name: "Dog"},
    {Name: "Cat"},
    {Name: "Elephant"}
);
  1. Run the app to initialize the collection by clicking App → OnStart → Run OnStart.

    222

Step 2: Create App Screen with Label, and Buttons

Add Controls to the Screen

  1. Create Screen - Concat_Function_Screen

  2. Insert the following controls from the Insert menu:

    • Label → This will display the concatenated results.

      • Set its Name to Label2_9.

      • Set Text property to "Please Select a Category" ( initially).

    • Buttons → For different categories. Add four buttons:

      1. Button2 → Text: Get Fruits

      2. Button2_1 → Text: Get Cars

      3. Button2_2 → Text: Get Animals

      4. Button2_3 → Text: Clear

        333

Step 3: Update the Label

  • Select the Label control (lblOutput).

  • Set its Text property to the following formula:

Switch(
    varSelected,
    "Fruit", Concat(colFruits, Name, ", "),
    "Car", Concat(colCars, Name, ", "),
    "Animal", Concat(colAnimals, Name, ", "),
    "None", "Please select a category",
    "Please select a category"
)

Explanation:

  • varSelected → The variable that stores which category the user selected.

  • "Fruit" → If the variable is "Fruit", it concatenates all names in colFruits.

  • "Car" → Concatenates all names in colCars.

  • "Animal" → Concatenates all names in colAnimals.

  • "None" → Default message when no category is selected.

  • The last "Please select a category" is a fallback in case the variable has an unexpected value.

    444

Step 4: Set varSelected on Every Button

Update Button OnSelect Properties

  1. Get Fruits Button

Set(varSelected, "Fruit")
  1. Get Cars Button

Set(varSelected, "Car")
  1. Get Animals Button

Set(varSelected, "Animal")
  1. Clear Button

Set(varSelected, "None")
555

How It Works

  • When a button is clicked, varSelected is updated to the corresponding category.

  • The label’s Text property uses the Switch() function from Step 3 to check the value of varSelected and display the right list.

  • Clicking Clear sets varSelected to "None", so the label shows the default message.

Step 5: Test the App

  1. Click the Play button (▶️) in Power Apps Studio to run the app.

  2. Test Each Button

    1. Click Get Fruits

      • The label should show:

      Apple, Banana, Orange
    2. Click Get Cars

      • The label should update to:

      BMW, Tesla, Audi
    3. Click Get Animals

      • The label should update to:

      Dog, Cat, Elephant
    4. Click Clear

      • The label should show the default message:

      Please select a category
      666
  • Concat() does not filter or select the category itself — it only combines the values of the collection you give it.

  • The Switch() function decides which collection to pass to Concat() based on the varSelected variable.

  • This is why only the selected category’s items appear in the label at any time.

Conclusion

In this article, we explored how to use the Concat() function in Power Apps to combine multiple values from a collection into a single text string. By combining Concat() with the Switch() function and a variable (varSelected), we created a dynamic app where only the selected category — Fruits, Cars, or Animals — is displayed in a label.