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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
NJ13
Helper I
Helper I

Multiple Columns

Hello All,

I'm struggling with the following. I have different columns which shows various labels with different categories.  Here is an example of data. i have deliminated the data in PowerBI and i looks like this.

NJ13_1-1643684303877.png

 

i am trying to do a stacked bar and i have tried almost everything to figure out  a way to get a total count of each category across all columns withougth duplicating or giving inconsistent numbers or giving couple answers for each category. is there a way i can get one for each and add them together (sum) and automate that process for repetitveness ?

 

thank you so much for your help

1 ACCEPTED SOLUTION

@NJ13 Right, so, again, the best solution would be to unpivot your columns in your first table, form a relationship between the two tables and then it is simply a COUNTROWS. Otherwise, you will need to use MC Aggregations like this:

 

Count MC Aggregations Column =
  VAR __Service = 'Table2'[Service]
  VAR __Column1 = SELECTCOLUMNS('Table1',"__Column",[Column1]
  VAR __Column2 = SELECTCOLUMNS('Table1',"__Column",[Column2]
  VAR __Column3 = SELECTCOLUMNS('Table1',"__Column",[Column3]
  VAR __Column4 = SELECTCOLUMNS('Table1',"__Column",[Column4]
  VAR __Table = UNION(__Column1, __Column2, __Column3, __Column4)
RETURN
  COUNTROWS(FILTER(__Table, [__Column] = __Service))
  

 


Follow on LinkedIn
@ 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...

View solution in original post

6 REPLIES 6
NJ13
Helper I
Helper I

Hello,

   i have a question in regards to Multiple columns... i have 34 rows with 14 different columns with different text categories  (e.g cleate, jerseys, socks, shorts, and pants) all 14 categories/columns where transforned by delimination.... i need to find counts of each the categories.. is there a way of going about it without adding a count formula and minimizing manual work?

Hi @NJ13 

 

Try to unpivote your table in Power Query, then you can use Attribute or Value columns to find the count of each categories with some filters.

 

https://docs.microsoft.com/en-us/power-query/unpivot-column

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

NJ13
Helper I
Helper I

@Greg_Deckler i have two tables one with the below texts and the other i shared above

NJ13_0-1643730279635.png

i want to count for each of these texts words in the other table for each column and then will sum them up after getting the counts. do you think that is possible ? if so can you please help me out with a formula and/or how to do it?

 

thank you 

 i have two tables one with the below texts and the other i shared above

NJ13_0-1643730739836.png

 

i want to count for each of these texts words in the other table for each column and then will sum them up after getting the counts. do you think that is possible ? if so can you please help me out with a formula and/or how to do it?

@NJ13 Right, so, again, the best solution would be to unpivot your columns in your first table, form a relationship between the two tables and then it is simply a COUNTROWS. Otherwise, you will need to use MC Aggregations like this:

 

Count MC Aggregations Column =
  VAR __Service = 'Table2'[Service]
  VAR __Column1 = SELECTCOLUMNS('Table1',"__Column",[Column1]
  VAR __Column2 = SELECTCOLUMNS('Table1',"__Column",[Column2]
  VAR __Column3 = SELECTCOLUMNS('Table1',"__Column",[Column3]
  VAR __Column4 = SELECTCOLUMNS('Table1',"__Column",[Column4]
  VAR __Table = UNION(__Column1, __Column2, __Column3, __Column4)
RETURN
  COUNTROWS(FILTER(__Table, [__Column] = __Service))
  

 


Follow on LinkedIn
@ 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...
Greg_Deckler
Super User
Super User

@NJ13 So typically you would unpivot the columns and then it is simple, you can use DISTINCTCOUNT for example. Otherwise, you could use MC Aggregations with a COUNTROWS(DISTINCT(UNION(...)))

Multi-Column Aggregations (MC Aggregations) - Microsoft Power BI Community

 


Follow on LinkedIn
@ 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...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.