Nov 18 2019 07:09 AM
Hello,
This is the first time I post!
I need to do the following. I have a dataset and one of the fields is made up of cells that can have multiple values. For example the below. We have cells that contain zero, one or multiple names and I would need to count those names like in a pivot table. These names are separated by an "enter". In the example below I put the desired output.
2019 | 2018 | |
Class 1 | John Mary | Mary Joseph Matthew |
Class 2 | Theresa Anthony | Matthew Margaret |
Class 3 | John Theresa | Theresa Margaret |
Desired output:
Number of Classes | ||
Person | 2019 | 2018 |
John | 2 | 0 |
Theresa | 2 | 1 |
Thanks in advance!
Nov 18 2019 07:23 AM
Solution@Ugarte335 I used Powerquery to massage your data as you can see in the attached file. From the green table it'll be easy to create your pivottable report. You can also feed the result of the query into the pivottable directly without using the intermediate green table of course.
Nov 18 2019 07:50 AM
Thank you, this was much easier than I expected!
Nov 18 2019 08:46 AM
I modified the Query to transform the data in the desired format which you showed in the description.
Please refer to the attached.
Nov 18 2019 09:07 AM
Just for the collection, here is a bit another version of query, resulting table is in brown.
Nov 19 2019 01:33 AM
Thank you so much for your help@Sergei Baklan
However, I tried with the data downloaded from the provider and it does not recognise it as new line for some reason. The delimiter with the data I provided first was a new line and it was recognised by power query.
Now it doesn't. I have attached the spreadsheet for your convenience.
Thanks
Nov 19 2019 02:58 AM
It works with your file, please checked attached. I converted the data into the table to simplify, by that doesn't matter. You may use range or query sheet from another file.
Generated script is
let
Source = Excel.CurrentWorkbook(){[Name="tblNames"]}[Content],
#"Added Custom" = Table.AddColumn(
Source,
"Name",
each Text.Split([Names],"#(lf)")
),
#"Expanded Custom" = Table.ExpandListColumn(
#"Added Custom",
"Name"
),
#"Removed Other Columns" = Table.SelectColumns(
#"Expanded Custom",
{"Country", "Name"}
)
in
#"Removed Other Columns"
Nov 18 2019 07:23 AM
Solution@Ugarte335 I used Powerquery to massage your data as you can see in the attached file. From the green table it'll be easy to create your pivottable report. You can also feed the result of the query into the pivottable directly without using the intermediate green table of course.