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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jeffr024
New Member

Counting number of patient modules within a date range

HI!

   I have a table with one row per patient and several variables tracking modules completed by putting in the date the module was delivered.  I would like to create a variable that counts the number of modules completed within the start and stop dates.  Can someone help me with the code for this type of variable creation?  Thanks so much!

 

PatientIntroModule1Module2 Module3 Module4 StartDateEndDate
112/3/20213/3/20223/15/2022  1/1/20223/31/2022
211/16/202112/20/20212/20/20223/3/2022 1/1/2022 3/31/2022
1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

HI @jeffr024 ,

Please try this:-

Column = 
var mod_1 = IF([Module1]<> blank(),IF(DATEVALUE([Module1]) >= [StartDate] && DATEVALUE([Module1]) <= 'Table (2)'[EndDate],1,0),0)
var mod_2 = IF([Module2 ]<> blank(),IF(DATEVALUE([Module2 ]) >= [StartDate] && DATEVALUE([Module2 ]) <= 'Table (2)'[EndDate],1,0),0)
var mod_3 = IF([Module3 ]<> BLANK(),IF(DATEVALUE([Module3 ]) >= [StartDate] && DATEVALUE([Module3 ]) <= 'Table (2)'[EndDate],1,0),0)
var mod_4 = IF([Module4 ]<> BLANK(),IF(DATEVALUE([Module4 ]) >= [StartDate] && DATEVALUE([Module4 ]) <= 'Table (2)'[EndDate],1,0),0)
return mod_1+mod_2+mod_3+mod_4

Output:-

Samarth_18_0-1647029754231.png

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

3 REPLIES 3
Samarth_18
Community Champion
Community Champion

HI @jeffr024 ,

Please try this:-

Column = 
var mod_1 = IF([Module1]<> blank(),IF(DATEVALUE([Module1]) >= [StartDate] && DATEVALUE([Module1]) <= 'Table (2)'[EndDate],1,0),0)
var mod_2 = IF([Module2 ]<> blank(),IF(DATEVALUE([Module2 ]) >= [StartDate] && DATEVALUE([Module2 ]) <= 'Table (2)'[EndDate],1,0),0)
var mod_3 = IF([Module3 ]<> BLANK(),IF(DATEVALUE([Module3 ]) >= [StartDate] && DATEVALUE([Module3 ]) <= 'Table (2)'[EndDate],1,0),0)
var mod_4 = IF([Module4 ]<> BLANK(),IF(DATEVALUE([Module4 ]) >= [StartDate] && DATEVALUE([Module4 ]) <= 'Table (2)'[EndDate],1,0),0)
return mod_1+mod_2+mod_3+mod_4

Output:-

Samarth_18_0-1647029754231.png

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Thank you so much!  This worked great!

jeffr024
New Member

Also I would like this count for each patient.  Thanks!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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