Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

Count occurance of a value in a column from Get items or HTML Table

(0) ShareShare
ReportReport
Posted on by 12,548 Super User 2025 Season 1
hey everybody 

i have a question. i have a get items action (basically 2 for each location) and inside my Sahrepoinlist there is a column called Gericht. The value of this column changes every week so the solution has to be dynamic.

I need to count how often the same value exists in the get items,count them and include it in the send email step. The solution is about meal ordering. I have a step that creates an html table, so if its easier to count from the table i am fine with it too.


i already tried a few things with loops and variables but wasnt able to fix it

if you have further questions let me know.



cheers
  • mmbr1606 Profile Picture
    12,548 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table
     
    thanks for helping, everything worked now.
     
    i split 1 flow into 2 so i have seperate ones for every location.

    i wanted to mark your answer as solution but right now its loading forever, i will for sure mark it and try again later/tomorrow.
     
     or can you have a look if you can mark yours by urself? as super user u have the ability to do this, if not please let me know
  • Chriddle Profile Picture
    7,772 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table
    So don't merge the lists from "Get items", but build this behavior twice.
  • mmbr1606 Profile Picture
    12,548 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table
    thank you 
     
    switching to the old designer solved the issue, i am now recieving the count from the items.

    i send 2 seperate emails one for Wels and one for Marchtrenk. I would need to only include the count for wels in the wels email and only the count for marchtrenk in the marchtrenk email.

    how can i add this step?
     
    right now i inserted the dynamic content : Output of create html table

    thanks in advance
  • Chriddle Profile Picture
    7,772 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table
    This is a bug in the new user interface. Either switch back to the classic user interface or remove all line breaks in my expressions.
    I recommend the latter the first option, as the new user interface is too buggy. :(
     
     
    If I insert the (correct) expression ...
     
     
    ... only some of the line breaks are handled properly (green), others get an additional backslash (yellow).
    Seems like the automatic encoding is getting a bit out of control ;)
     
     
    In the old UI this works fine
  • mmbr1606 Profile Picture
    12,548 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table


    what i have now is after the get items i inserted a compose with both get items in it
     
     
     
    then i inserted a Select with this in From:
     
    union(	
    	xpath(
    		xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
    		'//Gericht/text()'
    	),
    	json('[]')
    )
    this gives me this error:
     
    The input parameter(s) of operation 'Select' contains invalid expression(s). Fix invalid expression(s) for the input parameter(s) of operation 'Select'.
     
    when i map Gericht with item() in the expression it inserts like this:
     
    in the number matching i use:
     
    xpath(
    	xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
    	concat('count(//Item[Gericht="', item(), '"])')
    )
    can you tell me what is wrong with the select input parameter?
     
  • Chriddle Profile Picture
    7,772 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table
    Prepare an HTML table for the email content:
     
    From:
    body('Select')
     
  • Chriddle Profile Picture
    7,772 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table
    The Compose is just mocking a "Get items".
    Either replace outputs('Compose') with outputs('Get_items')?['body/value'] in my expressions or just keep the Compose and use outputs('Get_items')?['body/value'] as its input.
     
    With 2 lists just combine them with the function union() (here in Compose 3) and use its output in the Select.
     
     
    Compose 3:
    union(
    	outputs('Compose'),
    	outputs('Compose_2')
    )
    Select:
    From:
    union(	
    	xpath(
    		xml(json(concat('{"Root":{"Item":', outputs('Compose_3'), '}}'))),
    		'//Gericht/text()'
    	),
    	json('[]')
    )
    Map Gericht:
    item()
    Map Number:
    xpath(
    	xml(json(concat('{"Root":{"Item":', outputs('Compose_3'), '}}'))),
    	concat('count(//Item[Gericht="', item(), '"])')
    )
     
  • mmbr1606 Profile Picture
    12,548 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table
     
    thanks for your reply.
     
    where would i insert these steps? as i have 2 locations i would need these steps for every of them or can i reuse it?

    the compose you inserted here, can i make this dynamic aswell, cause now it has static values, right?
     
    what do i insert in the send email step to make it visible there?

    pasting this into from in select gives me :

    The input parameter(s) of operation 'Select' contains invalid expression(s). Fix invalid expression(s) for the input parameter(s) of operation 'Select'
    union(	
    	xpath(
    		xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
    		'//Gericht/text()'
    	),
    	json('[]')
    )

     
    cheeers
  • Chriddle Profile Picture
    7,772 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table
    From below, it is a simple step to make this dynamic:
     
     
    From:
    union(	
    	xpath(
    		xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
    		'//Gericht/text()'
    	),
    	json('[]')
    )
     
    Map Gericht:
    item()
     
    Map Number:
    xpath(
    	xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
    	concat('count(//Item[Gericht="', item(), '"])')
    )
     
  • Chriddle Profile Picture
    7,772 Super User 2025 Season 1 on at
    Count occurance of a value in a column from Get items or HTML Table
    The shortest and fastest way to count elements is probably to use XPath:
     
    xpath(
    	xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
    	'count(//Item[Gericht="Bratwurst"])'
    )
     
     

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

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >