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

Handling tag data in a table

Hi all,

I went through the posts but couldn't find an answer to the following question (apologies if I missed it).

I have a table that has a field containing a list of tags (I can format this string as I want)  but I would like to aggregate data by tag rather than bu the whole string.

Example, I have a table with 2 rows:

ID-1<tag1>,<tag2>
ID-2<tag2>

I would like data to be aggregated this way:

<tag1> 1 record

<tag2> 2 records

Instead of this way:

 <tag1>,<tag2> 1 record

<tag2> 1 records

 

Is there a way I can do that?

 

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Handling tag data in a table

Hi @elettra84 ,

 

You could open query editor and unpivot the tag columns to get an extra column. Then pivot this column to get IDs without aggregation and remove blank tags.

Here is my test file for your reference.

 

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

View solution in original post

4 REPLIES 4
Highlighted
Community Champion
Community Champion

Re: Handling tag data in a table

Is there a clear delimiter that separates the tags? If so, you could add a step in Power Query Editor that does a split column by delimiter and expand the advanced options to split into rows rather than columns.

 


______________


Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 


If you found this post helpful, please give Kudos.


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


https://sites.google.com/site/allisonkennedycv

Highlighted
New Member

Re: Handling tag data in a table

I was thinking about this solution, however in that table I also have metrics that shouldn't be duplicated as it will double/triple count them. What do you suggest?

Highlighted
Community Champion
Community Champion

Re: Handling tag data in a table

@elettra84  One option in that case is to split the table into 2 - what I sometimes do in this case is right click on the table query and choose 'reference' to create the additional tables. Keep the Key ID column in both tables, but only keep the Tags in one table and only the other info in the other table. Relate them in the data model and carry on as normal. 

 

Does that make any sense?

 


______________


Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 


If you found this post helpful, please give Kudos.


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


https://sites.google.com/site/allisonkennedycv

Highlighted
Community Support
Community Support

Re: Handling tag data in a table

Hi @elettra84 ,

 

You could open query editor and unpivot the tag columns to get an extra column. Then pivot this column to get IDs without aggregation and remove blank tags.

Here is my test file for your reference.

 

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

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors