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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
nitinbhai
Regular Visitor

How can we count from the single column have diffrrent names within same cells by using GroupBy?

 

   

 

4 ACCEPTED SOLUTIONS

@nitinbhai you should unpivot your data 

 

- transform data
- select Id and status column in your table
- right-click, unpivot other columns it will add two columns, attribute, and value, rename these as per your requirement
- close and apply

To visualize,
- matrix visual:
- add attribute on rows,
- add status on columns
- add id on values section with aggregation as count

this is the best approach and you will able to slice/dice the data as per your business requirement and it is scalable solution 

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

hi  @nitinbhai 

First, for your case, you'd better unpivot your data as parry2k solution.

https://radacad.com/pivot-and-unpivot-with-power-bi

 

And that will change your data structure, otherwise, you need to create measure for each color as below:

Red = COUNTROWS(FILTER('Table','Table'[Color1]="Red"))+COUNTROWS(FILTER('Table','Table'[Color2]="Red"))+COUNTROWS(FILTER('Table','Table'[Color3]="Red"))+COUNTROWS(FILTER('Table','Table'[Color50]="Red"))

White = COUNTROWS(FILTER('Table','Table'[Color1]="White"))+COUNTROWS(FILTER('Table','Table'[Color2]="White"))+COUNTROWS(FILTER('Table','Table'[Color3]="White"))+COUNTROWS(FILTER('Table','Table'[Color50]="White"))

Blue = COUNTROWS(FILTER('Table','Table'[Color1]="Blue"))+COUNTROWS(FILTER('Table','Table'[Color2]="Blue"))+COUNTROWS(FILTER('Table','Table'[Color3]="Blue"))+COUNTROWS(FILTER('Table','Table'[Color50]="Blue"))

Black = COUNTROWS(FILTER('Table','Table'[Color1]="Black"))+COUNTROWS(FILTER('Table','Table'[Color2]="Black"))+COUNTROWS(FILTER('Table','Table'[Color3]="Black"))+COUNTROWS(FILTER('Table','Table'[Color50]="Black"))

 

Then create a visual as below:

4.JPG

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Also, one important thing once we do pivot for the existing data in powerbi, it will works when add new data monthly from the source, unpiviot automatically transpose data and update monthly automatically when we refresh data...is that correct?

 

It is really appreciate your support so far.

View solution in original post

hi  @nitinbhai 

You just need to unpivot color columns in power query.

yes, if there are 100 columns, you need to write 100 measure for 100 multiple response to combine, so it is better unpivot all the color columns into one column to calculate them together.

 

Yes, if the data structure are same, it will automatically transpose data.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

11 REPLIES 11
az38
Community Champion
Community Champion

Hi @nitinbhai 

please, provide more details about your requirements: data sample and desired output


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

IDColor1Color2Color3Color50Status
1RedBlueBlackWhiteLow
2 BlueBlackWhiteHigh
3  BlackWhiteMedium
4Red Black High

 

I have data like above table, and needs to count based on status vs. color... desired output will be like below

 LowMediumHigh
Red1 1
Blue1 1
White111
Black112

hi  @nitinbhai 

First, for your case, you'd better unpivot your data as parry2k solution.

https://radacad.com/pivot-and-unpivot-with-power-bi

 

And that will change your data structure, otherwise, you need to create measure for each color as below:

Red = COUNTROWS(FILTER('Table','Table'[Color1]="Red"))+COUNTROWS(FILTER('Table','Table'[Color2]="Red"))+COUNTROWS(FILTER('Table','Table'[Color3]="Red"))+COUNTROWS(FILTER('Table','Table'[Color50]="Red"))

White = COUNTROWS(FILTER('Table','Table'[Color1]="White"))+COUNTROWS(FILTER('Table','Table'[Color2]="White"))+COUNTROWS(FILTER('Table','Table'[Color3]="White"))+COUNTROWS(FILTER('Table','Table'[Color50]="White"))

Blue = COUNTROWS(FILTER('Table','Table'[Color1]="Blue"))+COUNTROWS(FILTER('Table','Table'[Color2]="Blue"))+COUNTROWS(FILTER('Table','Table'[Color3]="Blue"))+COUNTROWS(FILTER('Table','Table'[Color50]="Blue"))

Black = COUNTROWS(FILTER('Table','Table'[Color1]="Black"))+COUNTROWS(FILTER('Table','Table'[Color2]="Black"))+COUNTROWS(FILTER('Table','Table'[Color3]="Black"))+COUNTROWS(FILTER('Table','Table'[Color50]="Black"))

 

Then create a visual as below:

4.JPG

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I have thousands of raws of data and needed to be count multiple response from col1 to col 50 vs. status. It is really appreciated your help if any we can do in powerbi without stacking data.

@nitinbhai you should unpivot your data 

 

- transform data
- select Id and status column in your table
- right-click, unpivot other columns it will add two columns, attribute, and value, rename these as per your requirement
- close and apply

To visualize,
- matrix visual:
- add attribute on rows,
- add status on columns
- add id on values section with aggregation as count

this is the best approach and you will able to slice/dice the data as per your business requirement and it is scalable solution 

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

As you mentioned select ID and status columns then pivot, then do i need to select the multiple column for the color:1-50 columns as well when we select unpivot.

 

How about if we 3 different scenario like

1. multiple column of color

2. multiple columnd of author

3. multiple column of areas

 

if we need to transfrom data by selecting uniqueid and status vs. all 3 different scenario OR can we indivual unpivot  by selecting status and id vs. scenario1

selecting status and id vs. scenario2

selecting status and id vs. scenario3

 

Also using below query infidivually

Red = COUNTROWS(FILTER('Table','Table'[Color1]="Red"))+COUNTROWS(FILTER('Table','Table'[Color2]="Red"))+COUNTROWS(FILTER('Table','Table'[Color3]="Red"))+COUNTROWS(FILTER('Table','Table'[Color50]="Red"))

White = COUNTROWS(FILTER('Table','Table'[Color1]="White"))+COUNTROWS(FILTER('Table','Table'[Color2]="White"))+COUNTROWS(FILTER('Table','Table'[Color3]="White"))+COUNTROWS(FILTER('Table','Table'[Color50]="White"))

Blue = COUNTROWS(FILTER('Table','Table'[Color1]="Blue"))+COUNTROWS(FILTER('Table','Table'[Color2]="Blue"))+COUNTROWS(FILTER('Table','Table'[Color3]="Blue"))+COUNTROWS(FILTER('Table','Table'[Color50]="Blue"))

Black = COUNTROWS(FILTER('Table','Table'[Color1]="Black"))+COUNTROWS(FILTER('Table','Table'[Color2]="Black"))+COUNTROWS(FILTER('Table','Table'[Color3]="Black"))+COUNTROWS(FILTER('Table','Table'[Color50]="Black"))

 

it's a lot when we have 100 multiple columns, so i need to write 100 measure for 100 multiple response to combine.

 

Also, one important thing once we do pivot for the existing data in powerbi, it will works when add new data monthly from the source, unpiviot automatically transpose data and update monthly automatically when we refresh data...is that correct?

 

It is really appreciate your support so far.

hi  @nitinbhai 

You just need to unpivot color columns in power query.

yes, if there are 100 columns, you need to write 100 measure for 100 multiple response to combine, so it is better unpivot all the color columns into one column to calculate them together.

 

Yes, if the data structure are same, it will automatically transpose data.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@nitinbhai great your issue is resolved but it is weird that you marked your own reply as a solution. Maybe that's what it is but it will more useful if you mark accept the actual post as a solution that helps to resolve your problem so that other can get benefit from it. Just a thought.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@nitinbhai add a new measure

 

Measure = COUNTROWS ( Table )

 

drop a table visual, add your column and mesure (above) in the visual and you will have it.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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