cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Modified 'Basket Analysis' - don't count when Item = Filter Item

Hi,

 

I have a list containing Order Number and Materials, where I need to figure out how many orders have the same pair of materials.

 

I've solved this using a Basket Analysis which works, where I put the measure in a table, with Materials_Primary and Materials_Filter.

However, I need to correct the measure, such that I don't get a count when Materials_Primary = Materials_Filter.

I.e. I don't want a count for 2002489 / 2002489, but I do want a count for 3024240 / 2002489.

 

How do I correct the measure to achieve this?

 

Used measure:

Orders with both products = 
CALCULATE (
    DISTINCTCOUNT ( 'Sales'[Order number] );
    CALCULATETABLE (
        SUMMARIZE ( 'Sales'; Sales[Order number] );
        ALL ( 'Sales' );
        USERELATIONSHIP ( 'Sales'[Materials]; Materiale_Filter[Materials] )
    )
)

Output example:

Tabel.PNG

Used Model:

Model.PNG

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Anonymous

 

Add EXCEPT ( Materiale_Filter; Material ) to CALCULATETABLE - see below.

 

By the way, I would have expected ALL ( Materiale ) rather than ALL ( 'Sales' ) in the standard Basket Analysis measure pattern, as you would clear filters other than Materiale. But if it works for you that's fine

 

Orders with both products = 
CALCULATE (
    DISTINCTCOUNT ( 'Sales'[Order number] );
    CALCULATETABLE (
        SUMMARIZE ( 'Sales'; Sales[Order number] );
        ALL ( 'Sales' );
        USERELATIONSHIP ( 'Sales'[Materials]; Materiale_Filter[Materials] );
        EXCEPT ( Materiale_Filter; Materiale )
    )
)


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @Anonymous

 

Add EXCEPT ( Materiale_Filter; Material ) to CALCULATETABLE - see below.

 

By the way, I would have expected ALL ( Materiale ) rather than ALL ( 'Sales' ) in the standard Basket Analysis measure pattern, as you would clear filters other than Materiale. But if it works for you that's fine

 

Orders with both products = 
CALCULATE (
    DISTINCTCOUNT ( 'Sales'[Order number] );
    CALCULATETABLE (
        SUMMARIZE ( 'Sales'; Sales[Order number] );
        ALL ( 'Sales' );
        USERELATIONSHIP ( 'Sales'[Materials]; Materiale_Filter[Materials] );
        EXCEPT ( Materiale_Filter; Materiale )
    )
)


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

 

Can you help me understand if it is possible to add a date dimension to it like in the below table?

 

Thumbnail

 

Helpful resources

Announcements
Power BI Show Episode 10 Recap

The Power BI Community Show

Watch the playback when Amit Chandak, a Power BI Super User, demos how to use Field Parameters to make reports more dynamic.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.

Ignite 2022

What's Next at Microsoft Ignite 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Top Solution Authors