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

Summing values of comma separated instances

I am trying to sum the number of instances in a comma separated list. For example, I am looking at website data and want to know the number of hits on each page type tagged to multiple criteria. 

Type Number
News, Sport, Business 20
News 6
Business, Sport 15
Sport, News 12
Sport 7

Desired result Number
News 38
Business 35
Sport 54

 

I am struggling to create the calculation that produces the breakdown for each type (see desired result). 

 

I have tried using column "split", so that the type becomes 3 columns Type.1, Type.2 and Type.3 and then get stuck. 

 

Can someone point me the way to deal with this issue?

 

3 REPLIES 3
v-danhe-msft
Employee
Employee

Hi @Anonymous,

Based on my test, you could refer to below steps:

1.Sample data (I have splited the "Type" column to 3 columns)

1.PNG

2.Unpivot the three type columns.

2.PNG

3.After unpivot remove the Attribute column.

3.PNG

4.Group by the [Value] column and you could get the correct result.

4.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/f6k1jmqlntxqj7e/Summing%20values%20of%20comma%20separated%20instances.pbix?dl=0

 

Regards,

Daniel He

 

 

 

 

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

Thanks @v-danhe-msft @jthomson for helpful replies. This partly resolves the problem. However, this exposes an issue! My dataset is actually more complicated as I have an additional column (and more in reality) called "Name". I need to be able to see the overall picture of "Number by Type" which this does. But when I consider this additonal column, the method creates an additional row for each delimited value causing issues on overall view where I see 3x Article A value, 2x Articles C and D value. 

 

I have not grouped any data as I am not sure how this exactly works. 

 

Essentially if I just filter by single layer i.e. Sport this works perfectly, but if I want to see the overall picture it doesn't.

Filtered view okFiltered view okOverall contains duplicationOverall contains duplication

My desired overall result would be to some see both views including an overview akin to the original view when no filters applied and total as achieved for filtered views. 

PowerBI_screengrab3.PNG

 

Any ideas how this can be achieved? I attach my PowerBI sample file TIA 🙂


 

 

 

 

jthomson
Solution Sage
Solution Sage

When you say you got stuck, that's a bit vague - are you at a stage like this:

 

unpivot.PNG

 

If so, pick the column with your numbers and select unpivot other columns. You may then need to trim your descriptor column depending on your exact data type, but once you've done that you can do what you need to do

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.