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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

 

1 ACCEPTED SOLUTION

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.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
Greg_Deckler
Super User
Super User

I created a quick measure for things like this, you can see it here:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Count-of-List-Items/m-p/350084

 

Welcome!!


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
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

Hi,

 

You may refer to my soluion in this file.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Ashish - thanks for the quick response and sorry for my delay getting back to you.  You did it!  I wanted to verfiy that I could re-create the solution on my side but got caught up in some other work. 

 

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Looks like it works Ashish, thanks!  I have some questions so I can repeat the solution.

- How did you split the backup out?

- How do I create the column "Index"?  Is is a basic function that Power BI will do in creating the split?

- How do I create the column "Back-up combination", it looks like a concatination of the index and the split backup column but it is not a calculated measure.  How do you do this?

 

I'm sorry for the newbie questions.  Thanks for your valuable time.

Anonymous
Not applicable

Also - is the table pirmary supplier names needed?  It is blank as far as I can see.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.