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 / XML > Select > Count /...
Power Automate
Unanswered

XML > Select > Count / Sum issue

(1) ShareShare
ReportReport
Posted on by 6
Hi,
I have admitted defeat, I can't see the issue...

Followed this great video to use xpath, select, compose for sum and count.
https://www.youtube.com/watch?v=z5MxbwURV68

Now instead of IDs I need to use something else.  I'm looking at a ticket system.
TicketID
Assigned To
etc

I used 'Assigned To' names instead of TicketID
My select fails every time...
xpath(outputs('Compose_XML'),'(//values/[Assigned_x005F_x0020_To/DisplayName=',item(),']/ItemInternalId)')

Could it be due to one of my Assign To names being null?
Where could I best handle that null with a coalesce?

InvalidTemplate
The execution of template action 'Select_XPATH_Name' failed: The evaluation of 'query' action 'where' expression '{ "Name": "@item()", "Count": "@xpath(outputs('Compose_XML'),concat('count(//values[Assigned_x005F_x0020_To/DisplayName=',item(),']/ID)'))", "Sum": "" }' failed: 'The template language function 'xpath' parameters are invalid: the 'xpath' parameter must be a supported, well formed XPath expression. Please see https://aka.ms/logicexpressions#xpath for usage details.'.
Categories:
I have the same question (1)
  • WillPage Profile Picture
    2,307 Super User 2025 Season 2 on at
    It looks like you haven't specified the XPATH function you want to do, e.g 
     
    xpath(outputs('Compose_XML'),'count(//values/[Assigned_x005F_x0020_To/DisplayName=',item(),']/ItemInternalId)')
  • TS-24071424-0 Profile Picture
    6 on at
    I kept searching and watching and found another example.  This one using length and double quotes worked...
     
    length(xpath(outputs('Compose_XML'),concat('//values[Assigned_x005F_x0020_To/DisplayName/text()="',item(),'"]')))
  • TS-24071424-0 Profile Picture
    6 on at
    These also worked but is not what I need.  Originally I was using the ticket ID which I couldn't de-dupe / union / aggregate.
    Then switched to using Name which threw up the posted issue.
     
    xpath(outputs('Compose_XML'),
    concat('(//values[ID=',item(),']/Assigned_x005F_x0020_To/DisplayName)[1]/text()')
    )?[0]
     
    xpath(outputs('Compose_XML'),concat('count(//values[ID=',item(),']/ID)'))

    This will bring back all the names for all the ticket IDs, so I get duplicated names.

    Data is structured

    TciketID  Name   Status
    1   Joe    Active
    2   Tim    Active
    3   Tim    Resolved
    4   Joe    Active
    5   Bob    Active
    6   null   Unassigned
     
  • CFernandes Profile Picture
    8,402 Most Valuable Professional on at
    Hey Mate, Could you please share the XML file you’re working with? Feel free to replace any sensitive or actual data with dummy values.

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard