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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
LucaN123
Frequent Visitor

Count and visualize data cells which contain several values (products)

Hi, 

 

I have just started to use Power BI and kindly ask for some support regarding how to visualize and count cells that contain multiple values (products). 

 

I have a table which shows different projects and the products that have been sold in this project. In addtion, the table contains many other columns such as e.g. the region. The column with the products sold contains cells with only one product and cells that contain multiple products separated by a semicolon (see example below)

 

I would like to show different reports and visualize the data. For example,

  • to show which products have been sold in which region
  • to show the products sold in a specific reporting period
  • to show all the products that are already implemented

What is the best way to show achieve this?

I have tried to use the "split column by delimiter function into rows" (in Power BI query), but the problem is that all other rows and values are duplicated. This causes an issue with other visuals that I have created (e.g., bar chart to show how many projects we had in a reporting period / Or how many ongoing projects we have vs. implemented projects). As multiple rows are added for all the cells that contain multiple products, the data for the other columns is also duplicated and seems to be counted incorrectly for other visuals. 

 

Maybe there is an easy solution to acheive what I want here, but I kindly ask for support!

 

StatusProjectProducts soldRegionReporting Period
ImplementedProject AProduct ANorthern EuropeQ1

Implemented

Project B

Product B; Product ASouthern EuropeQ2
OngoingProject CProduct A; Product B; Product CWestern EuropeQ1
ImplementedProject DProduct BWestern EuropeQ2
2 ACCEPTED SOLUTIONS

Hi,

Please read up on the CONCATENATEX() function.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Hi @LucaN123 ,

 

I suggest you to duplicate the [Products sold] in Power Query Editor and then split the duplicated one.

vrzhoumsft_0-1706510158563.png

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.

vrzhoumsft_1-1706510600658.png

 

Best Regards,
Rico Zhou

 

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

7 REPLIES 7
LucaN123
Frequent Visitor

Thank you for your response. Your solutions worked well, but I have another issue that emerged because I have slightly changed the table view. I have a column now which lists all the products sold for a specific project in one row like displayed below (Products combined). I would like to create another customized column which checks the products combined column and returns values based on the following: 

- If products combined column is empty, return empty

- If products combined column contains exactly "Product A,Product B", return Product A including B

- If products combined column contains at least two of the following words/products (Product A, Product B, Product C, Product D), return Solution Project

- Otherwise return value of Products combined column. 

 

I have tried to use the formula further down below, but apparently there is a mistake in the third IF statement and the result is not displayed correctly (see below in red).  Would be great if you could advise what the mistake is here? If there is an easier way to achieve the expected result, please let me know. Thank you!

 

IDProducts combinedProduct Reporting (current result)Product Reporting (expected result)
1Product AProduct AProduct A
2Product A,Product BProduct A including Product BProduct A including Product B
3Product A,Product B,Product C, Product DProduct A,Product B,Product C, Product DSolution Project
4Product A,Product FProduct A,Product FProduct A,Product F

 

 

IF(
    ISBLANK('Dashboard'[ProductsCombined]),
    BLANK(),
    IF(
        'Dashboard'[ProductsCombined] = "Product A,Product B",
        "Product A including Product B",
        IF(
            CALCULATE(
                COUNTROWS(
                    FILTER(
                        VALUES('Dashboard'[ProductsCombined]),
                        COUNTROWS(
                            INTERSECT(
                                VALUES('Dashboard'[ProductsCombined]),
                                {"Product A", "Product B", "Product C", "Product D", "Product E", "Product F", "Product G"}
                            )
                        )
                    )
                )
            ) >= 2,
            "Solution Project",
            'Dashboard'[ProductsCombined]
        )
    )
)

 



Ashish_Mathur
Super User
Super User

Hi,

Splitting data by rows is the way to go.  Once you do so, share the questions that you need answers to.  Also, show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Ok, I have done the splitting by rows. In my report view, I have several visuals where I show some data for the projects by country or status (e.g., bar chart: Y-axis --> country, X-axis --> Count of projects/id).

 

I have the following questions: 

  1.  I would like to show all projects by country but the total number of projects is incorrect --> I think I found the solution but can someone please confirm that the correct way is to count of ID to Count of ID (distinct)? 
  2. I would like to include a table visual in the report to show detailed information for the different projects (including products). In this case, I would like the products not to be separated into different rows.

This is the current view: 

IDProjectsProductsRegionOpportunity value
ID 117Project XProduct ANorthern Europe10000 €
ID 117Project XProduct BNorthern Europe10000 €
ID 4Project DProduct ASouthern Europe5000 €

 

I would like to see the following view. So basically I need the same "cell value" again before the delimination where the products where combined. Otherwise, it the table shows the same projects multiple times with the only difference in the product column. Ideally, I would like to create another column (not existing) which shows "multi-product projects" for all projects including several products. Can I create this with a formula? 

ID 117Project XProduct A, Product Bmulti-product projectNorthern Europe
ID 4Project DProduct AProduct A

Southern Europe

 

 

3. I would like to show other visuals for example the total value by region (e.g., pie chart: Values --> Sum of opportunity value, Details: Region). But this visual shows now 20.000 € (Northern Europe) vs. 5000 € (Southern Europe) which is incorrect. Correct would be 10.000 € vs. 5000€. How can I avoid that these values are summed up for the addtional rows that are created by the delimination?

 

Apologies for all the questions. I have tried to look for some videos on this, but I don't even know exactly what to search for to describe what I would like to built. Hope with the explanation above it is clear. Thanks in advance for any support on my questions!

 

 

Hi,

For th e first one, write this measure

Number of projects = distinctcount(Data[Projects])

I cannot understand your second question.

For the third one, write these measures

Measure = min(Data[Opportunity value])

Measure1 = SUMX(VALUES(Data[Projects]),[Measure])

Use measure 1 in all your visuals where you want to see project wise totals.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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: 

IDProjectsProductsRegionStatus
ID 1Project XProduct A; Product B; Product CNorthern EuropeOngoing
ID 2Project YProduct BNorthern EuropeImplemented

 

Current view: 

IDProjectsProductsRegionStatus
ID 1Project XProduct ANorthern EuropeOngoing
ID 1Project XProduct BNorthern EuropeOngoing
ID 1Project XProduct CNorthern EuropeOngoing
ID 2Project YProduct BNorthern EuropeImplemented

 

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).

 

IDProjectsProductsProducts 2
ID 1Project XProduct A; Product B; Product CMulti-product project
ID 2Project YProduct BProduct 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 @LucaN123 ,

 

I suggest you to duplicate the [Products sold] in Power Query Editor and then split the duplicated one.

vrzhoumsft_0-1706510158563.png

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.

vrzhoumsft_1-1706510600658.png

 

Best Regards,
Rico Zhou

 

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

Hi,

Please read up on the CONCATENATEX() function.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.