Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Newbie needing simple? table calculation help

Hi - I'm hoping someone can help me.   I'm very new, literally hours in, and a recent convert to Power BI from Tableau.  I just couldn't take the special way you needed to do and think about things differently using Tableau.  Unfortunately, I did have some dashboards already built that I need to re-create in Power BI.  Anyway...

 

I need to count the occurrence of a name in a semicolon separated column of data.  I need the count to be in a table with the count of another name field.  I tried some simple functions and can't seem to get the calculation to work.  In the example data attached, I need a count of the occurrences of the Primary & Back-up name columns.  A simple count only counts the occurrences where the entire combined data exists.  Hard to explain but looking at the data should help.  I also don't know how to do simple stuff yet like add grand totals and subtotals to the columns.  I'm good at Excel pivot tables, and I'm guessing it is similar in a Matrix - - just haven't figured out where everything is yet.

 

I have a spreadsheet with example data in a table, and the answer I'd like to obtain from in a Matrix.  I also have the data in Power BI Matrix desktop file.  I'd appreciate if someone could help me out sooner than later if possible.  The link will take you to the files.  https://drive.google.com/open?id=1dYXi75tZ4TXxiBuMjfLmkPTP8c7WRNbI

 

  • Ashish_Mathur's avatar
    Ashish_Mathur
    8 years ago

    Hi,

     

    Go to Home > Edit Queries and click on the Table named Data to see the transformation steps i applied.  Here are the answers to your specific questions:

     

    1. Using Data > Split column > Advanced > By rows
    2. Done in the Query Editor.  Once click solution to create an Index column
    3. Done in the Query Editor.

    If my previous reply helped, please mark as Answer.

8 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi - thanks for the reply, but I don't think this is the solution I was looking for.  For your table, the answer I'd be looking for would be the count of all the occurrences of "One" in the column, the count of all the occurences of "Two" in the column, and the count of all the occurences of "Three" in the column.  Example;

       

      Column 1      Column 2                     Count of Occurences of Column 1 in Column 2

      One               One                                  3

      Two               One, Two                          2

      Three             One, Two, Three               1

       

      If you do understand, I have a sligthly more complex example in the files.  If you could put the solution in the Power BI file or use the following data set.  I REALLY appreciate the help.

       

        Type              Primary                Back-up

      SupplierRobert SmithJames Johnson;Maria Garcia
      CustomerMaria GarciaMary Smith;Bob Williams;James Johnson
      InternalMary SmithRobert Smith
      InternalJames JohnsonBob Williams;Robert Smith;Mary Smith
      CustomerBob WilliamsRobert Smith;Maria Garcia
      SupplierRobert SmithJames Johnson
      SupplierRobert Smith 
      SupplierRobert Smith 
      InternalMary SmithMaria Garcia
      CustomerMaria GarciaBob Williams;James Johnson
      InternalBob WilliamsJames Johnson;Mary Smith
      CustomerRobert SmithBob Williams

       

      The answer I'm looking for is

       Customer  Internal  Supplier     
      PrimaryCount of PrimaryCount of Back-upTotal CustomerCount of PrimaryCount of Back-upTotal InternalCount of PrimaryCount of Back-upTotal SupplierTotal Count of PrimaryTotal Count of Back-upGrand Total
      Bob Williams134112000246
      James Johnson022112022156
      Maria Garcia213011011235
      Mary Smith011224000235
      Robert Smith112022404538
      Total48124711437121830