How to concatenate multiple rows from an other table in DAX?










0















I'm new to Power BI and I need to concatenate in a new column Suppliers_List all the suppliers for a given item.



I have a table Orders where I need to create the column :



Order_Number Customer_ID Item_Number
0001 1 1
0002 2 1
0003 1 3
0004 1 4
0005 3 2
0006 3 2
0007 4 2


A table Items where a same product can have multiple supplier:



Unique_ID Item_Number Supplier_ID Item_Name
1 1 1 "wheel"
2 1 2 "wheel"
3 2 1 "door"
4 2 2 "door"
5 3 1 "motor"
6 3 3 "motor"
7 4 4 "dashboard"


And a table Suppliers :



Supplier_ID Supplier_Name
1 "Metal&co"
2 "SmithSE"
3 "BetterMotors"
4 "TinyCircuits"


I'm trying to get the following result in the table Orders where I store the suppliers name, separated by a comma :



Order_Number Customer_ID Item_Number Suppliers_List
0001 1 1 "Metal&co, SmithSE"
0002 2 1 "Metal&co, SmithSE"
0003 1 3 "Metal&co, BetterMotors"
0004 1 4 "TinyCircuits"
0005 3 2 "Metal&co, SmithSE"
0006 3 2 "Metal&co, SmithSE"
0007 4 2 "Metal&co, SmithSE"


I know that the dax expression for my column Suppliers_List probably deals with Concatenate and GroupBy functions but I don't have the knowledge to get it.



The solution I'm thinking of is to group the field Item_Number from the table Items and concatenate the field Supplier_Name from table Suppliers.



my not working try :



Suppliers_list = CONCATENATE(GROUPBY('Items';Suppliers[Supplier_Name]) ; ", ")


Can someone help ?



UPDATE



I finaly found something way far from my first guess.



See my anwser.










share|improve this question




























    0















    I'm new to Power BI and I need to concatenate in a new column Suppliers_List all the suppliers for a given item.



    I have a table Orders where I need to create the column :



    Order_Number Customer_ID Item_Number
    0001 1 1
    0002 2 1
    0003 1 3
    0004 1 4
    0005 3 2
    0006 3 2
    0007 4 2


    A table Items where a same product can have multiple supplier:



    Unique_ID Item_Number Supplier_ID Item_Name
    1 1 1 "wheel"
    2 1 2 "wheel"
    3 2 1 "door"
    4 2 2 "door"
    5 3 1 "motor"
    6 3 3 "motor"
    7 4 4 "dashboard"


    And a table Suppliers :



    Supplier_ID Supplier_Name
    1 "Metal&co"
    2 "SmithSE"
    3 "BetterMotors"
    4 "TinyCircuits"


    I'm trying to get the following result in the table Orders where I store the suppliers name, separated by a comma :



    Order_Number Customer_ID Item_Number Suppliers_List
    0001 1 1 "Metal&co, SmithSE"
    0002 2 1 "Metal&co, SmithSE"
    0003 1 3 "Metal&co, BetterMotors"
    0004 1 4 "TinyCircuits"
    0005 3 2 "Metal&co, SmithSE"
    0006 3 2 "Metal&co, SmithSE"
    0007 4 2 "Metal&co, SmithSE"


    I know that the dax expression for my column Suppliers_List probably deals with Concatenate and GroupBy functions but I don't have the knowledge to get it.



    The solution I'm thinking of is to group the field Item_Number from the table Items and concatenate the field Supplier_Name from table Suppliers.



    my not working try :



    Suppliers_list = CONCATENATE(GROUPBY('Items';Suppliers[Supplier_Name]) ; ", ")


    Can someone help ?



    UPDATE



    I finaly found something way far from my first guess.



    See my anwser.










    share|improve this question


























      0












      0








      0








      I'm new to Power BI and I need to concatenate in a new column Suppliers_List all the suppliers for a given item.



      I have a table Orders where I need to create the column :



      Order_Number Customer_ID Item_Number
      0001 1 1
      0002 2 1
      0003 1 3
      0004 1 4
      0005 3 2
      0006 3 2
      0007 4 2


      A table Items where a same product can have multiple supplier:



      Unique_ID Item_Number Supplier_ID Item_Name
      1 1 1 "wheel"
      2 1 2 "wheel"
      3 2 1 "door"
      4 2 2 "door"
      5 3 1 "motor"
      6 3 3 "motor"
      7 4 4 "dashboard"


      And a table Suppliers :



      Supplier_ID Supplier_Name
      1 "Metal&co"
      2 "SmithSE"
      3 "BetterMotors"
      4 "TinyCircuits"


      I'm trying to get the following result in the table Orders where I store the suppliers name, separated by a comma :



      Order_Number Customer_ID Item_Number Suppliers_List
      0001 1 1 "Metal&co, SmithSE"
      0002 2 1 "Metal&co, SmithSE"
      0003 1 3 "Metal&co, BetterMotors"
      0004 1 4 "TinyCircuits"
      0005 3 2 "Metal&co, SmithSE"
      0006 3 2 "Metal&co, SmithSE"
      0007 4 2 "Metal&co, SmithSE"


      I know that the dax expression for my column Suppliers_List probably deals with Concatenate and GroupBy functions but I don't have the knowledge to get it.



      The solution I'm thinking of is to group the field Item_Number from the table Items and concatenate the field Supplier_Name from table Suppliers.



      my not working try :



      Suppliers_list = CONCATENATE(GROUPBY('Items';Suppliers[Supplier_Name]) ; ", ")


      Can someone help ?



      UPDATE



      I finaly found something way far from my first guess.



      See my anwser.










      share|improve this question
















      I'm new to Power BI and I need to concatenate in a new column Suppliers_List all the suppliers for a given item.



      I have a table Orders where I need to create the column :



      Order_Number Customer_ID Item_Number
      0001 1 1
      0002 2 1
      0003 1 3
      0004 1 4
      0005 3 2
      0006 3 2
      0007 4 2


      A table Items where a same product can have multiple supplier:



      Unique_ID Item_Number Supplier_ID Item_Name
      1 1 1 "wheel"
      2 1 2 "wheel"
      3 2 1 "door"
      4 2 2 "door"
      5 3 1 "motor"
      6 3 3 "motor"
      7 4 4 "dashboard"


      And a table Suppliers :



      Supplier_ID Supplier_Name
      1 "Metal&co"
      2 "SmithSE"
      3 "BetterMotors"
      4 "TinyCircuits"


      I'm trying to get the following result in the table Orders where I store the suppliers name, separated by a comma :



      Order_Number Customer_ID Item_Number Suppliers_List
      0001 1 1 "Metal&co, SmithSE"
      0002 2 1 "Metal&co, SmithSE"
      0003 1 3 "Metal&co, BetterMotors"
      0004 1 4 "TinyCircuits"
      0005 3 2 "Metal&co, SmithSE"
      0006 3 2 "Metal&co, SmithSE"
      0007 4 2 "Metal&co, SmithSE"


      I know that the dax expression for my column Suppliers_List probably deals with Concatenate and GroupBy functions but I don't have the knowledge to get it.



      The solution I'm thinking of is to group the field Item_Number from the table Items and concatenate the field Supplier_Name from table Suppliers.



      my not working try :



      Suppliers_list = CONCATENATE(GROUPBY('Items';Suppliers[Supplier_Name]) ; ", ")


      Can someone help ?



      UPDATE



      I finaly found something way far from my first guess.



      See my anwser.







      powerbi dax






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 14:35







      Ceci Semble Absurde.

















      asked Nov 15 '18 at 10:11









      Ceci Semble Absurde.Ceci Semble Absurde.

      7719




      7719






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I finaly found something way far from my first guess.



          First, you need to create a new column Supplier_Name in the table Items where you will store value in the field Supplier_Name from Suppliers. I've achieve it like so :



          Supplier_Name = CONCATENATEX (
          FILTER ( Suppliers; Items[Supplier_ID] = Suppliers[Supplier_ID] );
          Suppliers[Supplier_Name];
          ""
          )


          Now that we have our Supplier_Name in our table Items, we can compute the suppliers list by grouping every product and concatenate the supplier name in a new column Suppliers_List.



          Suppliers_List = CONCATENATEX (
          FILTER ( Items; Items[Item_Number] = EARLIER ( Items[Item_Number] ) );
          Items[Supplier_Name];
          ", "
          )


          You can now import it in a visualization element such as a table.



          Hopping that will help the community






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317030%2fhow-to-concatenate-multiple-rows-from-an-other-table-in-dax%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I finaly found something way far from my first guess.



            First, you need to create a new column Supplier_Name in the table Items where you will store value in the field Supplier_Name from Suppliers. I've achieve it like so :



            Supplier_Name = CONCATENATEX (
            FILTER ( Suppliers; Items[Supplier_ID] = Suppliers[Supplier_ID] );
            Suppliers[Supplier_Name];
            ""
            )


            Now that we have our Supplier_Name in our table Items, we can compute the suppliers list by grouping every product and concatenate the supplier name in a new column Suppliers_List.



            Suppliers_List = CONCATENATEX (
            FILTER ( Items; Items[Item_Number] = EARLIER ( Items[Item_Number] ) );
            Items[Supplier_Name];
            ", "
            )


            You can now import it in a visualization element such as a table.



            Hopping that will help the community






            share|improve this answer



























              0














              I finaly found something way far from my first guess.



              First, you need to create a new column Supplier_Name in the table Items where you will store value in the field Supplier_Name from Suppliers. I've achieve it like so :



              Supplier_Name = CONCATENATEX (
              FILTER ( Suppliers; Items[Supplier_ID] = Suppliers[Supplier_ID] );
              Suppliers[Supplier_Name];
              ""
              )


              Now that we have our Supplier_Name in our table Items, we can compute the suppliers list by grouping every product and concatenate the supplier name in a new column Suppliers_List.



              Suppliers_List = CONCATENATEX (
              FILTER ( Items; Items[Item_Number] = EARLIER ( Items[Item_Number] ) );
              Items[Supplier_Name];
              ", "
              )


              You can now import it in a visualization element such as a table.



              Hopping that will help the community






              share|improve this answer

























                0












                0








                0







                I finaly found something way far from my first guess.



                First, you need to create a new column Supplier_Name in the table Items where you will store value in the field Supplier_Name from Suppliers. I've achieve it like so :



                Supplier_Name = CONCATENATEX (
                FILTER ( Suppliers; Items[Supplier_ID] = Suppliers[Supplier_ID] );
                Suppliers[Supplier_Name];
                ""
                )


                Now that we have our Supplier_Name in our table Items, we can compute the suppliers list by grouping every product and concatenate the supplier name in a new column Suppliers_List.



                Suppliers_List = CONCATENATEX (
                FILTER ( Items; Items[Item_Number] = EARLIER ( Items[Item_Number] ) );
                Items[Supplier_Name];
                ", "
                )


                You can now import it in a visualization element such as a table.



                Hopping that will help the community






                share|improve this answer













                I finaly found something way far from my first guess.



                First, you need to create a new column Supplier_Name in the table Items where you will store value in the field Supplier_Name from Suppliers. I've achieve it like so :



                Supplier_Name = CONCATENATEX (
                FILTER ( Suppliers; Items[Supplier_ID] = Suppliers[Supplier_ID] );
                Suppliers[Supplier_Name];
                ""
                )


                Now that we have our Supplier_Name in our table Items, we can compute the suppliers list by grouping every product and concatenate the supplier name in a new column Suppliers_List.



                Suppliers_List = CONCATENATEX (
                FILTER ( Items; Items[Item_Number] = EARLIER ( Items[Item_Number] ) );
                Items[Supplier_Name];
                ", "
                )


                You can now import it in a visualization element such as a table.



                Hopping that will help the community







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 14:33









                Ceci Semble Absurde.Ceci Semble Absurde.

                7719




                7719





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317030%2fhow-to-concatenate-multiple-rows-from-an-other-table-in-dax%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Barbados

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3