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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to concatenate values from multiple rows

(0) ShareShare
ReportReport
Posted on by 55

Hello Experts

I'm working with report. I have a situation similar to classic

ID - EXTID - VALUE

1 - 1 - Val1

2 - 1 - Val2

I need to concatenate values

( Final result : 1 - Val1, Val2 )

using SQL 2 CDS tool (then I will traslate it in FetchXML);

I tried WITH CTE, FOR XML PATH, with no luck

How can I complete this task?

Thanks

I have the same question (0)
  • Suggested answer
    Carlik Profile Picture
    55 on at
    RE: How to concatenate values from multiple rows

    Your last link was helpful!

    Thanks

  • Verified answer
    Wahaj Rashid Profile Picture
    11,321 on at
    RE: How to concatenate values from multiple rows

    Hi,

    Thank you for your query.

    In SQL Server you can use STRING_AGG() for this purpose.

    For example:

    SELECT [IDColumn], STRING_AGG([ValueColumn], ',') [ContactVal]
    
    FROM Table1
    
    GROUP BY [IDColumn]

    However, as far as I know, this will not work in SQL 4 CDS (it does not support STRING_AGG).

    Also, the fetch xml has limited aggregation options (Sum, Count, Avg etc.):

    Use FetchXML aggregation (Microsoft Dataverse) - Power Apps | Microsoft Docs

    I guess, your only option is to user grouping in SSRS report (not in the query) or use Join operation in SSRS expressions to concatenate values form rows:

    reporting services - How to convert multiple rows into one row in SSRS? - Stack Overflow

    SSRS concatenate field in one string delimited by comma - without SQL (microsoft.com)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 155

#2
DAnny3211 Profile Picture

DAnny3211 89

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 68 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans