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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Measure question: Specific combination of products within same period of time

Hello community members, 

 

I have a question: 

I would like to know how many times it happens that a client hires the specific combination of 2 products (10B02 and 02A02) during the same period. It is not necessary that the hiring period is completely the same, but there should be at least 1 day overlap. 

 

Below you find a sample of the data. The last two rows for client BW03 (made them bold) meet the requirements and should therefore 'show up' in the measure.

 

CLIENTPRODUCTCODESTARTDATEENDDATE
BW0110B011-1-202230-6-2022
BW0107A021-3-20221-5-2022
BW0207A021-1-202231-3-2022
BW0210A061-1-202231-7-2022
BW0302A021-1-20221-5-2022
BW0310B021-6-202231-10-2022
BW0302A021-11-202231-12-2022
BW0310B021-12-202215-12-2022

 

Can anyone help me? 

 

Hope to hear soon from you! 

 

Best regards,

 

Sander

 

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can create a measure

Ordered at same time = SUMX( VALUES(Orders[CLIENT]),
var product1 = CALCULATETABLE( 
    SELECTCOLUMNS( SUMMARIZE( Orders, Orders[STARTDATE], Orders[ENDDATE]), "Prod1 Start", [STARTDATE], "Prod1 End", [ENDDATE])
    , Orders[PRODUCTCODE] = "10B02")
var product2 = CALCULATETABLE( 
    SELECTCOLUMNS( SUMMARIZE( Orders, Orders[STARTDATE], Orders[ENDDATE]), "Prod2 Start", [STARTDATE], "Prod2 End", [ENDDATE])
    , Orders[PRODUCTCODE] = "02A02")
var allOrders = CROSSJOIN(product1, product2)
return SUMX( allOrders,
    IF( ISEMPTY( INTERSECT( DATESBETWEEN( 'Date'[Date], [Prod1 Start], [Prod1 End]), DATESBETWEEN( 'Date'[Date], [Prod2 Start], [Prod2 End]))), 0, 1)
)
)

This will also count any times when there are multiple overlaps, i.e. a customer hired product 1 and then hired product 2 twice within the period.

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

You can create a measure

Ordered at same time = SUMX( VALUES(Orders[CLIENT]),
var product1 = CALCULATETABLE( 
    SELECTCOLUMNS( SUMMARIZE( Orders, Orders[STARTDATE], Orders[ENDDATE]), "Prod1 Start", [STARTDATE], "Prod1 End", [ENDDATE])
    , Orders[PRODUCTCODE] = "10B02")
var product2 = CALCULATETABLE( 
    SELECTCOLUMNS( SUMMARIZE( Orders, Orders[STARTDATE], Orders[ENDDATE]), "Prod2 Start", [STARTDATE], "Prod2 End", [ENDDATE])
    , Orders[PRODUCTCODE] = "02A02")
var allOrders = CROSSJOIN(product1, product2)
return SUMX( allOrders,
    IF( ISEMPTY( INTERSECT( DATESBETWEEN( 'Date'[Date], [Prod1 Start], [Prod1 End]), DATESBETWEEN( 'Date'[Date], [Prod2 Start], [Prod2 End]))), 0, 1)
)
)

This will also count any times when there are multiple overlaps, i.e. a customer hired product 1 and then hired product 2 twice within the period.

amitchandak
Super User
Super User

@Anonymous , is it somthing similar to Market Basket Analysis ?


https://finance-bi.com/power-bi-basket-analysis/
https://businessintelligist.com/2017/03/27/market-basket-analysis-using-power-bi/
https://www.daxpatterns.com/usecases/market-basket-analysis/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak thanks for your reply. Just looked at the information, but is it is not the answer to my question, because there is no startdate and enddate involved.

 

I know how to make the measure for; count the number of times someone has product A as well as product B, but i don't know how I need to insert the part of; and the product should be hired at the same time.  

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors