Forum Discussion
Count and visualize data cells which contain several values (products)
- 2 years ago
Hi,
Please read up on the CONCATENATEX() function.
- Anonymous2 years ago
Hi Anonymous ,
I suggest you to duplicate the [Products sold] in Power Query Editor and then split the duplicated one.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8swtyEnNTc0rSU1R0lEKKMrPSk0uUXCEsFNKoWy//KKSjNSiPAXX0qL8glSgSKChUqwOLu1OSNqdrBWQTQrOL0U3yQhskn9een5mXjqSKc7IjkCYgmQgSEV4anEJ8S5zQXYZVt1A18QCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Status = _t, Project = _t, #"Products sold" = _t, Region = _t, #"Reporting Period" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Status", type text}, {"Project", type text}, {"Products sold", type text}, {"Region", type text}, {"Reporting Period", type text}}), #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Products sold", "Products sold - Copy"), #"Reordered Columns" = Table.ReorderColumns(#"Duplicated Column",{"Status", "Project", "Products sold", "Products sold - Copy", "Region", "Reporting Period"}), #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Reordered Columns", {{"Products sold - Copy", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Products sold - Copy"), #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Products sold - Copy", type text}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Products sold - Copy", "Products sold -Splited"}}), #"Trimmed Text" = Table.TransformColumns(#"Renamed Columns",{{"Products sold -Splited", Text.Trim, type text}}) in #"Trimmed Text"Then create a measure to achieve your goal.
Products 2 = IF(CONTAINSSTRING(MAX('Table'[Products sold]),";"),"Multi-product project",MAX('Table'[Products sold]))Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Thanks for your answer to Question 1 + 3 - this works perfectly.
I will try to explain Question 2 in more detail - there are actually two sub-questions for this.
Question 2.1: Before I've separated the Products column by delimiter into rows, the product column contained both cells with only one product & multiple products in one cell.
In the report, I have used a "table visual" to show the information for the different projects and which products are included (see below). You could easily see if a project includes multiple products. As the products are now separated into multiple rows, the "table visual" also shows several rows for the same project (see current view). Is it possible to combine the different products again in one cell? Please note that I would still like to have the rows separate to count the products in other visuals. I would assume I need to create another column again in the table view which combines all products again in one cell (then I could use this column in the table visual instead).
Expected view:
| ID | Projects | Products | Region | Status |
| ID 1 | Project X | Product A; Product B; Product C | Northern Europe | Ongoing |
| ID 2 | Project Y | Product B | Northern Europe | Implemented |
Current view:
| ID | Projects | Products | Region | Status |
| ID 1 | Project X | Product A | Northern Europe | Ongoing |
| ID 1 | Project X | Product B | Northern Europe | Ongoing |
| ID 1 | Project X | Product C | Northern Europe | Ongoing |
| ID 2 | Project Y | Product B | Northern Europe | Implemented |
Question 2.2:
I would like to create another column or measure in my table view which shows if projects contain only one product or multiple products. If a project contains multiple products, the cell should display "Multi-product project". If a project contains only one product, the cell should display the product (see below in blue).
| ID | Projects | Products | Products 2 |
| ID 1 | Project X | Product A; Product B; Product C | Multi-product project |
| ID 2 | Project Y | Product B | Product B |
I hope you understand the question now. Otherwise, please let me know. I think the challenge is that I need to split the product column into separate rows to count and visualize the products in a better way. But for other visuals, I would need the column which contains all products combined in the cell.
Thanks in advance.
Hi,
Please read up on the CONCATENATEX() function.