cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Thinker77
New Member

How can I count the number of values accross all columns in a table?

I have many different surveys with their results in different tables but using the same scale (good, bad, ok, for example).  I want to count all the goods, bads and oks accross a table and then collate my results from all tables where I can see the results over time.  I tried using a formula like this: New Teacher Negative = COUNTAX('New Teachers', "Needs Improving") + COUNTAX('New Teachers', "Unsatisfactory") but it counts every row.  Surely there must be a way to do this fairly easily without adding a count from each column (some of the surveys are quite long).

 

Any suggestions?

1 ACCEPTED SOLUTION

Hi @Thinker77,

If all your five table have same columns and the format is same, please Append them to one table by using Append Queries in Query Edit.

1.PNG

Then create a calculated column to get the year, create measure to calculate the count of each type using the formula.



Year = YEAR(Table4[Date])

test = COUNTA(Table4[Apply Interview])


Capture11.PNG

Create two slicers including Year and Apply Interview fields. Create a table used to display the result.

Capture12.PNG

When you select diferent year and Apply interview,it will display different result.

In addition, if you want to count the number of values across all columns in a table. Please unpivot the columns except date field.

 

For the following table, you want to calculate the count the number of values for “Apply interview” and “Communication” columns. You can right click the table-> Edit Query, select the “Apply interview” and “Communication” columns->Unpivot columns under transform, you will get the following table.

Capture1.PNG

 

Finnaly, you can use the new column(highlighted in wire frame) and the solution above to calculate the desired result.

Capture14.PNG

If you have other issues, don't hesitate to let me know.

Best Regards,
Angelia

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

Some sample data would help, but you might create a central table with your survey answers using an Enter Data query to enter "good", "bad", "ok" or whatever, relate all of your survey tables to this central table and then create a custom column kind of like:

 

Count = COUNTAX('Table'[Column],RELATEDTABLE('Table')) + COUNTAX('OtherTable'[Column],RELATEDTABLE('OtherTable')) + ...

@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Hi,

 

Thanks for the idea.  I am planning on refreshing the data source (a collection of Excel files dumped out of Survey Monkey) in the future so I don't want to do any that would require someone else to need to rework the data afterwards.  Also, all the data is meaningful related (through collectors).  Here is a sample of the data I am working with:

 

SurveySample.JPG

 

I have 5 tables full of data, all related to each other and all with answers that follow a very predictable format like this.  Essentially I want to aggregate all the results so I can see if all the data from all the surveys points in the same direction.  On the dashboard, I want to have slicers that allow the viewer to effectively analyze the results by filtering out certain academic years or cohort types.  I want to count all the "high satisfactory" and "good" results from a whole table without necessarily having a count for each column (as there are many and they have crazy names that happen to be the survey question - which is useful).

 

I hope that clarifies things.  Any more ideas?  Thanks in advance!

Hi @Thinker77,

If all your five table have same columns and the format is same, please Append them to one table by using Append Queries in Query Edit.

1.PNG

Then create a calculated column to get the year, create measure to calculate the count of each type using the formula.



Year = YEAR(Table4[Date])

test = COUNTA(Table4[Apply Interview])


Capture11.PNG

Create two slicers including Year and Apply Interview fields. Create a table used to display the result.

Capture12.PNG

When you select diferent year and Apply interview,it will display different result.

In addition, if you want to count the number of values across all columns in a table. Please unpivot the columns except date field.

 

For the following table, you want to calculate the count the number of values for “Apply interview” and “Communication” columns. You can right click the table-> Edit Query, select the “Apply interview” and “Communication” columns->Unpivot columns under transform, you will get the following table.

Capture1.PNG

 

Finnaly, you can use the new column(highlighted in wire frame) and the solution above to calculate the desired result.

Capture14.PNG

If you have other issues, don't hesitate to let me know.

Best Regards,
Angelia

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors