web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Count distinct values ...
Power Automate
Unanswered

Count distinct values in SharePoint list and send HTML table of the values with its count in a table format

(0) ShareShare
ReportReport
Posted on by 21

I have a SharePoint list and contains multiple items with some single and some multiple values per schedule.  After each scheduled flow, all the SP items will be swept and I want to count each distinct entry in the Title column and each count should be sent in a table sent to email.  I can't find a way to filter the result with its count and combine it in one table.  below is the expected result

 

Title Name (alphabetized)Count

Title1

1
Title23
Title35
Title42
Title51
Categories:
I have the same question (0)
  • Verified answer
    v-jefferni Profile Picture
    on at

    Hi @jophi1124 ,

     

    Please follow below steps:

    vjefferni_0-1677047808347.pngvjefferni_1-1677047846856.png

    vjefferni_2-1677047883165.png

     

    The result HTML table can be used in Email body.

     

    Best regards,

  • jophi1124 Profile Picture
    21 on at

    Thank you for the response.  May I ask a few more nuances?

    1. I failed the Get items 2--one of the possible title contains apostrophe in the name so it got an error in the formula Title eq '@{items('Apply_to_each')?['Title']'.  Would you know how to get around it?

    2. Can you let me know what is the output 2 on the From on Create HTML table?  I do not seem to figure it out from the pictures.

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    This sounds harsh, but you should change the title name in the SharePoint list so that it doesn't have an apostrophe. It will help you in the long run.

     

     https://learn.microsoft.com/en-us/microsoft-365/community/sharepoint-naming-guidelines

     

    After you have to deal with residual problems enough you'll learn to fix column names up front. Give them an initial name that doesn't have any special characters so that it will be stored internally like that. Then go back and change the name after the column is made and the display name will be different but the internal name will always be the same.

  • v-jefferni Profile Picture
    on at

    Hi @jophi1124 ,

     

    Please find internal column names in the URL of the page that editing a column in list settings, then use them for filter query. For variable 2, it is actually variable 1, output from append to array variable in Apply to each. I edited names of the two variables but forgot to change it in the last action.

     

    Best regards,

  • jophi1124 Profile Picture
    21 on at

    v-jefferni, sorry for failing to make it clearer.  the error is below:

    jophi1124_0-1677140217591.png

     

    one of the entries under title column is:
    AMERICA'S....    that's why the flow stopped during Get items 2.  Is there a work around for that if there's apostrophe on the SahrePoint entry for cloumn Title (or any column from sharepoint with text format that may contain ' ?  other example we may get are ST. JOHN'S... etc.

    It's not the Title column header that has the apostrophe.

  • v-jefferni Profile Picture
    on at

    Hi @jophi1124 ,

     

    Column values will not cause that error.

     

    You can find the real column names from the outputs of the first Get items action in flow run history:

    vjefferni_0-1677142581262.png

    vjefferni_1-1677142646863.png

     

    You can press CTRL+F keys to search body in the page, and find the internal column name then copy it to filter query.

     

    Best regards,

  • jophi1124 Profile Picture
    21 on at

    Hi, I believe my issue is about this: https://powerusers.microsoft.com/t5/Building-Flows/Data-contains-an-apostrophe-and-gets-skipped/td-p/617219

     

    This is my raw data:

    jophi1124_0-1677146820520.png

    I ran your flow again and got this error:

    jophi1124_1-1677146907390.png

     

  • Verified answer
    v-jefferni Profile Picture
    on at

    Hi @jophi1124 ,

     

    So, have you tried below expression in filter query?

    replace(items('Apply to each')?['Title'],'''','''''')

     

    BR,

  • jophi1124 Profile Picture
    21 on at

    yes it worked now.  Thank you sooo much!

     

    Raw data: 4

    jophi1124_0-1677241266545.png

     

    Result: 4

     

    jophi1124_1-1677241327196.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard