Retrieve Hashtags from Text in a Canvas Power App | Power Platform

Let’s say you want to make a collection of Hashtags used in a certain Text Input control. Here’s how you do it using the HashTags() function in Power Apps.

Let me demonstrate it quickly below!

Using HashTags() function

Now, let’s consider the below scenario where you want to collect the Hastags from a Text Input and later on use business logic on that.

  1. As an example, let me take a Description multi-line text field on the Canvas App and I’ll also take a DataTable to show the collected Hashtags in the same.
    I’ve renamed the Text Input to “Description”

  2. Now, to scan for hashtags and collect them, I’m writing the below formula on the OnChange operation of thee Text Input so that once I finish writing and move the focus away from Text Input, the Formula can scan for Hashtags and populate the collection.



  3. Now, here’s the formula I’ve used to scan the Text (String) for Hashtags present.


    Microsoft Docs Link for HashTags() formula –
    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-hashtags?WT.mc_id=DX-MVP-5003911

    Why ClearCollect instead of Collect? – Because only using Collect will scan the field and add all the hashtags again causing redundancy.

    Why I used Collection? – I could also use this collection elsewhere instead of directly assigning the above formula to the Items of the Data Table. Hence, the preference to use ClearCollect.

  4. Now, from the Data Table perspective, I’m simply populating the Data Table with the Collection [hashtagCollection] as the Data Source and make sure you also add the Result column as well, else, the Data Table will be blank even if the Collection is being populated.

Working

Let’s see how the table will be populated as we Run the App.

  1. Now, I’ve written as Hello #PowerPlatform and moved the focus out of the Text Input, the Data Table (via Collections) is populated with the results.


  2. Again, if I add another Hashtag i.e. #PowerApps, it’ll add to the collection (Basically, erase everything and scan all over again behind the scenes)

To demonstrate this example, I’ve created a YouTube video for the same, kindly check it out!

Hope this was useful. Here are some more Power Apps / Power Platform posts you might want to check out –

  1. Rich Text Control for Canvas and Model-Driven App | Quick Tip
  2. Setting Correct Default Mode for Forms in a Canvas App | [Quick Tip]
  3. Rating Control to represent data from Dataverse in a Canvas Power App | Power Platform
  4. Clear a field value & Reset Form in a Canvas Power App [Quick Tip]
  5. Implement real-time search in Gallery of CDS records in a Canvas Power App | Power Platform
  6. Implement character length validation in a Canvas Power App | Power Platform
  7. Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
  8. Debug Published Canvas Power App with other users using Monitor | Power Platform
  9. AddColumns() function to dynamically add columns to a Data table in Canvas Power App | SharePoint List
  10. Log Canvas Power App telemetry data in Azure Application Insights | Power Apps

Thank you!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.