Concatenate and conatenatex

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 715334

    Comments posted to this topic are about the item Concatenate and conatenatex

  • handkot

    SSCarpal Tunnel

    Points: 4513

    I think the answer is 5, can also be considered correct

    or am i wrong?

    I Have Nine Lives You Have One Only
    THINK!

  • Carlo Romagnano

    SSC-Insane

    Points: 21743

    handkot (10/26/2016)


    I think the answer is 5, can also be considered correct

    or am i wrong?

    You're wrong!

    CONCATENATE concatenates only two string. CONCATENATE(<text1>,<text2>)

    CONCATENATEX concatenates ALL values of a table. See the parameter list:

    CONCATENATEX(<table>,<expression>,[separator])

    That's very simple!

    🙂

  • This was removed by the editor as SPAM

  • Ed Wagner

    SSC Guru

    Points: 286957

    Not being a PowerBI user, I learned something new. Thanks.

  • Koen Verbeeck

    SSC Guru

    Points: 258924

    handkot (10/26/2016)


    I think the answer is 5, can also be considered correct

    or am i wrong?

    CONCATENATE just pastes two strings (or columns together).

    CONCATENATEX is an iterator which goes over an entire table and concatenates all of the values together, using an optional delimiter.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen Verbeeck

    SSC Guru

    Points: 258924

    Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • TomThomson

    SSC Guru

    Points: 104765

    Nice question, but I think the explanation of concatenatex is a bit off - the elements that get concatenated are the results of evaluating the expression parameter on every row of the table denoted (or generated - the table parameter can be an expression instead of a table name) by the table parameter, so the explanation is incorrect unless the scalar expression parameter denotes a column of that table (and sometimes it doesn't). In the example given on the BoL page referenced the expression doesn't designate a column, it generates a scalar value from more than one element of the row it's applied to and it's those scalar values that get concatenated. For the same reason, I think it's a bit off to call the "expression" parameter the "column" parameter.

    Obviously concatenatex (T, Exp,D) = concatenate ((select Exp as Cname from T) Tab, Cname , D) [perhaps that's incorrect syntax in DAX, but DAX certainly has an equivalent table expression to the SQL subquery one] which is concatenating all the values in the single column Cname of the generated table, so it's not completely wrong/unacceptable to talk as if the scalar expression were a column name, as the explanation does. Just a bit off and may mislead people into thinking that the second parameter can only be a column name.

    Tom

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply