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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Amanda_Araujo
Frequent Visitor

A ranking for the top products sold together

Hello!

 

I have a basket market problem to solve. First, I did my basket market analysis by using this video from Enterprise DNA and it work really well. Then, I found a measure here  in PBI Community, to found the top combinations of products and it works too, but I can't use this measure to create a chart.

 

So what I need is: a ranking of the most sold together product that I can use to create a chart and a table.

 

All the codes that worked for me is down below:

 

THE BASKET ANALYSIS

Same Product Selected =
IF( SELECTEDVALUE( '@Cesta_Produtos'[ID] ) <> SELECTEDVALUE( WooCommerce[ID Produto] ),
 BLANK(),
  TRUE)
 
Customers Who Bought =
IF([Same Product Selected],
    BLANK(),
    DISTINCTCOUNT(WooCommerce[CPF ANONIMO NEW]))
 
Customers w/ both =
VAR MultiPurchaseEvaluation =
    CALCULATETABLE(VALUES(WooCommerce[CPF ANONIMO NEW]),
    ALL ('SKUs (2)'),
    USERELATIONSHIP(WooCommerce[ID Produto], '@Cesta_Produtos'[ID]))

RETURN
IF ([Same Product Selected] = TRUE,
    BLANK(),
        CALCULATE([Customers Who Bought], MultiPurchaseEvaluation))
 
TOP 10 COMBINATIONS
 
Highest Combo =
VAR cj1 =
    DISTINCT ( SELECTCOLUMNS (WooCommerce, "Product1", WooCommerce[Nome Curso]))
VAR cj2 =
    DISTINCT ( SELECTCOLUMNS ( WooCommerce, "Product2", WooCommerce[Nome Curso] ) )
VAR cj =
    FILTER ( CROSSJOIN ( cj1, cj2 ), [Product1] <> [Product2] )
VAR summary =
    ADDCOLUMNS (
        cj,
        "@total",
            VAR prod1 = [Product1]
            VAR prod2 = [Product2]
            RETURN
                COUNTROWS (
                    FILTER (
                        ALL ( WooCommerce[CPF ANONIMO NEW] ),
                        AND (
                            NOT ( ISBLANK ( CALCULATE ( COUNTROWS ( WooCommerce ), WooCommerce[Nome Curso] = prod1 ) ) ),
                            NOT ( ISBLANK ( CALCULATE ( COUNTROWS ( WooCommerce ), WooCommerce[Nome Curso] = prod2 ) ) )
                        )
                    )
                )
    )
VAR productslist =
    CONCATENATEX (
        TOPN ( 10, summary, [@total], DESC, [Product1], ASC ),
        [Product1] & " e " & [Product2] & UNICHAR(10)
    )
RETURN
    productslist
 
Thanks a lot!
0 REPLIES 0

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.