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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

count of frequency of overlaps based on time intervals

Hi, I would like to count the number ofoverlaps of 2 variables (drug 1 and drug 2) by duration; where the interval of drug 1 <90 days and interval of drug 2 <30 days.

In other words, how many occurance of drug 2 between the 90 days window of drug 1

 

fakladios_0-1606487795790.png

fakladios_1-1606487821836.png

 

Thank you so much and your help will be grealy appreciated

regards,

Fady

 
 

Note: The following measure was created but it did not calculate the proper frequency of overlap

 

CoAdmin Logic_MEASURE =

VAR vByeUswe = CALCULATETABLE(SUMMARIZE('Transformed Table', 'Transformed Table'[Date]),'Transformed Table'[Drug] = "2", 'Transformed Table'[Disp Inrtevals]<=30, 'Transformed Table'[Disp Inrtevals]>0)

VAR vIns = CALCULATETABLE(SUMMARIZE('Transformed Table', 'Transformed Table'[Date]), 'Transformed Table'[Drug] = "1", 'Transformed Table'[Disp Inrtevals]<=90, 'Transformed Table'[Disp Inrtevals]>0)

VAR Result = COUNTROWS(UNION(vByeUswe, vIns))

RETURN

Result

 

4 REPLIES 4
Anonymous
Not applicable

data sample

Index IDDrugDispDATEInrtevalsOverlap logic
0129/09/2012 282
1127/10/2012 282
21218/11/2012 424
31227/01/2013 704
41210/03/2013 424
51121/04/2013 421
6125/05/2013 142
7115/05/2013 141
8122/06/2013 282
91216/06/2013 142
101128/07/2013 421
111211/08/2013 142
121111/08/2013 141
131216/06/2013142

 

AntrikshSharma
Super User
Super User

@Anonymous What was wrong in your result? Please attach sample data, desired/correct result and how you are trying to visualize it.

Anonymous
Not applicable

fakladios_0-1606702731468.png

 

I managed to build a count of seq function in excel as shown above using nested if (as shown above) to count sequence of 1 followed by 2. Is it possible to build a similar measure in Dax

 

Thank you in advance and your help will be greatly appreciated

 

Fady

Anonymous
Not applicable

The Desired output : calculate the count of overlaps of logic 2 (drug 2 and interval =<30) happening in between logic 1 (drug 1 and interval =<90) for the same ID...In other words, we want to identify the sequential pattern of 1,2,1 or 1,2,2,1 in the table and count those overlaps 

 

Thank you so much.

 

Fady

 

fakladios_1-1606569776275.png

Note: : the previous measure shown earlier created a count of all rows in calculated table joining logic 2 and logic 1 but ignoring the dersired sequence of intervals, resuling in overestimating the occurences

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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