Forum Discussion

user180618's avatar
user180618
Helper I
6 years ago
Solved

Unique values dynamically linked to multiple value columns

I am trying to transform data from a SharePoint list in Power Query Editor. That List has several single value columns and several multiple choice value columns. What I would like is to have those multiple values relate to one unique value (which will be used as the Count value in the Power BI report). Here's an example of what I have and what I've tried:

 

NameAgeLocations livedLanguages spoken
John30[List][List]
Ben35[List][List]
Jerry40[List][List]

 

I've then applied 'Expand to new rows' to Locations lived and Languages spoken in Query Editor and got:

 

NameAgeLocations livedLanguages spoken
John30New YorkEnglish
John30ChicagoItalian
Ben35New YorkEnglish
Ben35SeattleFrench
Ben35Portlandnull
Jerry40San FranciscoEnglish
Jerry40Los AngelesSpanish

 

But this duplicates my Name column, so when I create a Report to see a chart of the unique count of Names and the multiple Languages spoken, it will count John's as two, Ben's as two and so on. Instead, I would like the values New York and Chicago, and English and Italian, to relate to one count for John. 

 

If I do this another way and Extract values and concatenate, and then drag the 'Name' column to Values (under Visualizations), it will count John once but also show 'New York,Chicago' as one value and 'English,Italian' as one value.

 

Any suggestions as to how I can have multiple values in a column relate to just one unique column (in this case 'Name')?

 

I've tried choosing 'Count (Distinct)' for every chart created in the report, but this works for simple Visualizations, and skews the data for more complex ones. So I'd rather do it right and link column dynamically in Query Editor, rather than manually selecting Distinct Count in the report every time.

7 Replies

  • I've gone with extracting and concatenating the values, so now have:

     

    NameAgeLocation livedLanguages spoken
    John30New York,ChicagoEnglish,Italian
    Ben35New York,Seattle,PortlandEnglish,French
    Jerry40San Francisco,Los AngelesEnglish,Spanish

     

    However, when I create a report and under Legend choose the column 'Location lived' and choose 'Count of Name' under Value, I cannot get it to show me the Location lived and Languages spoken values separately. So for example, I'd like a pie chart visualization for Ben to show me 1 count each for New York, Seattle and Portland, and 1 count each for English and French.

     

    Is there a way to do this without running an R script in Query Editor?

    • camargos88's avatar
      camargos88
      Community Champion

      user180618 ,

       

      Why don't you split the values by comma, so you can achieve it.

       

      Did I answer your question? Mark my post as a solution!
      Ricardo

      • user180618's avatar
        user180618
        Helper I

        I've already split them by commas in Query Editor (see previous post), but it comes out like this in the report:

         

         

        I'd like it to show me the count value for those cities separately, but for the Name column to be the main aggregator.

  • v-juanli-msft's avatar
    v-juanli-msft
    Community Support

    Hi 

    Is this problem sloved? 
    If it is sloved, could you kindly accept it as a solution to close this case and help the other members find it more quickly?
    If not, please feel free to let me know.
     
    Best Regards
    Maggie