Skip to main content

Notifications

Power Automate - Using Connectors
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.

  • MarceloBarroso Profile Picture
    MarceloBarroso 39 on at
    Re: Sum field through Select query in CDS/List records

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

     

    Best regards.

  • Helpful Profile Picture
    Helpful 382 on at
    Re: Sum field through Select query in CDS/List records

    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
    MarceloBarroso 39 on at
    Re: Sum field through Select query in CDS/List records

    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.

  • Verified answer
    v-siky-msft Profile Picture
    v-siky-msft on at
    Re: Sum field through Select query in CDS/List records

    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

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,636

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,942

Leaderboard

Featured topics