Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
john9inno
Creator
Creator

Market basket analysis

Hi all,

I have gone thorugh many of discussion and articles about Market Basket Analysis. (MBA)

all of them explans about how get MBA data for a seleted item or product.

However, I need to generate a full list that contains all items (about 200K SKUs) and 5 items next to it that shows highest co-occurence.

Can any one please give me a tip for this?

thanks in advance.

For below data, I need to generate the list that contains all Prod code, Associated Prod Code and frequency of Co-occurence.

LOAD * INLINE [

    Customer, InvoiceNo, Prod

    260690, 1, Tea

    260690, 1, Tea

    260690, 1, Fruit

    260690, 1, Fruit

    260690, 1, Fish

    260690, 1, Fish

    260690, 2, Tea

    260690, 2, Tea

    260690, 2, Fruit

    260690, 2, Fruit

    260690, 2, Fish

    260690, 1, Corn

    260690, 1, Corn

    260690, 1, Fruit

    260690, 1, Fruit

    260690, 1, Tea

    260690, 1, Tea

    260690, 3, Corn

    260690, 3, Corn

    260690, 3, Fruit

    260690, 3, Fruit

    260690, 3, Fish

    260690, 3, Fish   

    260690, 1, egg

    260690, 1, egg

    260690, 1, egg   

    221729, 3, Tea

    221729, 3, Tea

    221729, 3, Tea

    221729, 3, Tea

    221729, 3, Tea

    221729, 3, Tea

    3898439, 4, egg

    3898439, 4, Fruit

    3898439, 5, egg

    3898439, 5, Fruit

]
;

    

     

1 Solution

Accepted Solutions
prashantbaste
Partner - Creator II
Partner - Creator II

Hi

I think there is some problem in your data as each record is repeated twice.

Now answering to your mail answer - You need to make buckets of all possible combinations of Items & then check those into each invoice if combination is there in order.

[* Technical Hint: Assigning number to each item & use of loops will help to achieve this]

The top 5 count of these buckets will give your desired Market Basket Analysis.

Hope this will be helpful for you.

--

Regards,

Prashant P Baste

View solution in original post

7 Replies
john9inno
Creator
Creator
Author

please see amended question.

thanks so much for your kind comment.

Not applicable

Hi John,

What do you mean by co-occurrence in this context, share the expected output so that we can help you.

Regards,

Navdeep

tresesco
MVP
MVP

Like in attached sample qvw?

prashantbaste
Partner - Creator II
Partner - Creator II

Hi

I think there is some problem in your data as each record is repeated twice.

Now answering to your mail answer - You need to make buckets of all possible combinations of Items & then check those into each invoice if combination is there in order.

[* Technical Hint: Assigning number to each item & use of loops will help to achieve this]

The top 5 count of these buckets will give your desired Market Basket Analysis.

Hope this will be helpful for you.

--

Regards,

Prashant P Baste

antoniotiman
Master III
Master III

Hi John,

can You provide, at least, the expected result ?

Perhaps, like this

Regards,

Antonio

john9inno
Creator
Creator
Author

Problem solved.

THanks all for your valuable inputs.

ProductAssociate_productCo_Occurunce ( In same invoice)
eggCorn1
CornCorn2
FishCorn2
FruitCorn2
TeaCorn2
Cornegg1
Fishegg1
Teaegg1
eggegg3
Fruitegg3
eggFish1
CornFish2
FishFish3
FruitFish3
TeaFish3
CornFruit2
eggFruit3
FishFruit3
TeaFruit3
FruitFruit5
eggTea1
CornTea2
FishTea3
FruitTea3
TeaTea3