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 / Sum field through Sele...
Power Automate
Answered

Sum field through Select query in CDS/List records

(0) ShareShare
ReportReport
Posted on by 39

Hi all.

 

Thanks in advance for your support.

 

I'm not sure whether this would be possible, but certainly it would help a lot. I want to sum the values in a table field (CDS), similar to the SQL instruction "Select SUM(field_name) as total_amount from <table_name>" (returning the total amount in the <total_amount> field).

 

I tried something like this using the LIST RECORDS action, but it didn't work (see image). Does anyone know a way to do that??

image.png

 

This is the error received:

Term 'sum(clth_gross_billable_value) as valor_tributavel_total, sum(clth_invoice_item_value) as valor_faturavel_total' is not valid in a $select or $expand expression.

 

 

 

(PS: The solution of (1) initializing a float variable and (2) adding the values to the variable within a for_each action is what I am doing right now, and it works...    if it was possible to do what I wanted, it would be much better tough.)

 

Thank you very much.

Best regards.

Categories:
I have the same question (0)
  • Verified answer
    v-siky-msft Profile Picture
    on at

    Hi @MarceloBarroso ,

    Select is a query option from OData service, unlike the Select instruction in SQL Server. it allows the clients to requests a limited set of properties for each entity, see System Query Option $select .

    Hence, your requirement can't be achieved. The workaround for now is, as you said, initializing a variable and adding the values to the variable within a Apply_to_each action to sum a column. There is no better method for that in flow at present.

    Hope this helps.

    Sik

  • MarceloBarroso Profile Picture
    39 on at

    Hi @v-siky-msft 

     

    Thank you very much that. I thought it wouldn't be possible, but decided to ask anyway. At least we know Flow has a large road to improve yet, we may expect a lot for the years ahead.

     

    Thank you for the reference on oData query, it will be much helpful.

     

     

    Best wishes.

  • Helpful Profile Picture
    382 on at

    Hey @MarceloBarroso, you could use FetchXml with aggregate values.

    Something like this:  Using FetchXML with List records in CDS current environment 

    Using this approach I saw crazy performance improvement compared to nested loops.

     

  • MarceloBarroso Profile Picture
    39 on at

    Thank you, @Helpful . I'll try FetchXML to do this...   it seems it's going to help me in lots of things.

     

    Best regards.

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…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 398 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 323 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 183 Most Valuable Professional

Last 30 days Overall leaderboard