Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ccolletti
Helper I
Helper I

Combining Data, Separated by a Comma when Matching value in One Column in Power BI Desktop

Hi All,

 

I'm working on building a rollup of data to match Vendors to the State and Store numbers they work in. I was able to pull this data in Excel using TextJoin, but I want to utilize Power BI for when the dataset is refreshed to account for any new stores or vendors.

 

Currently in excel I'm using a similar formula to pull together the state and store numbers and I get the following data.

=TEXTJOIN(", ",TRUE,SORT(UNIQUE(IF('Vendor - Store List'!A:A='Vendor - Store Rollup'!A2,'Vendor - Store List'!C:C,""))))

ccolletti_0-1677262750708.png

 

In Power BI my data reads as the following:

ccolletti_1-1677262879881.png

I've attempted to use CONCATENATEX, CONCATENATEX(VALUES, and SUMMARIZE  from the following link with no results. The data I get back is every store number seperated by a comma for every vendor.

https://community.powerbi.com/t5/Desktop/excel-Text-Join-method-with-Dax/m-p/569470

 

Thank you all for your help and time looking into this!

 

9 REPLIES 9
Padycosmos
Solution Sage
Solution Sage

Padycosmos
Solution Sage
Solution Sage

This video illustrates how to combine rows in Power query

https://drive.google.com/file/d/1na2-YBiK2AGJVbmC85IQiue3E03uVikv/view?usp=share_link

@Padycosmos, unfortunelty I'm unable to access the video due to this being a work computer. Is it possible to post screenshots? Thank you!

Here are the screen shots:

Padycosmos_0-1677607605775.png

Padycosmos_1-1677607633295.png

Padycosmos_2-1677607677862.png

Padycosmos_3-1677607700333.png

 

 

ccolletti
Helper I
Helper I

@sevenhills Thank you for your help, this halfway helped me out.

 

Using the new measure within the table for the State worked perfectly, however the store is still not working correctly. Not sure what I'm missing as I did the fromula exactly how you wrote it out for both and the States came back fine, but the store still just pulled in every single store number.

ccolletti_0-1677599351963.png

 

@ccolletti , the logic is same and not sure where it went wrong. Can you post the DAX?

 

Simple thumb rule: it should work for both the same way. As you have seen, DAX is simple code. All we are doing is getting distinct and concatenex. 

@sevenhills, agreed I figured it would work with State working. And not able to post in DAX, table is locked down by IT. Only have the ability to access the data for design purposes.

It is not possible to help without knowing the table, dax and the issue.

 

Let us do Power Query route:
Ask them to try in Power Query and see if that works there?

 

Say, you have table as below:

sevenhills_0-1677615602724.png

 

Note: Store is marked as text.

 

Add a group by step as below:

= Table.Group(#"Changed Type", {"Vendor"}, 
        {
         {"States", each Text.Combine ( List.Distinct([State], Comparer.OrdinalIgnoreCase), ", "), type text}
         , {"Stores", each Text.Combine ( List.Distinct([Store], Comparer.OrdinalIgnoreCase), ", "), type text}
        })

 

and you can see the output as

sevenhills_1-1677615658581.png

 

Another advantage is Power Query stores, where as Measure calculates in run time. 

Hope this helps!

 

sevenhills
Super User
Super User

Two approaches, you can decided based on your needs.

 

1) Create new DAX table

2) Creating measures in the same table

 

sevenhills_0-1677274279874.png

New Table using DAX:

Table52Vendor_Rollup = 
    Summarize(
        Table52Vendor, Table52Vendor[Vendor], 
           "States", CONCATENATEX(DISTINCT(Table52Vendor[State]), Table52Vendor[State], ", "),
           "Stores", CONCATENATEX(DISTINCT(Table52Vendor[Store]), Table52Vendor[Store], ", ")
    )

 

New Measure within the table

Vendor States = CONCATENATEX(DISTINCT(Table52Vendor[State]), [State], ", ")

Vendor Stores = CONCATENATEX(DISTINCT(Table52Vendor[Store]), [Store], ", ")

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.