Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
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!
Patient | Intro | Module1 | Module2 | Module3 | Module4 | StartDate | EndDate |
1 | 12/3/2021 | 3/3/2022 | 3/15/2022 | 1/1/2022 | 3/31/2022 | ||
2 | 11/16/2021 | 12/20/2021 | 2/20/2022 | 3/3/2022 | 1/1/2022 | 3/31/2022 |
Solved! Go to Solution.
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:-
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
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:-
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!
Also I would like this count for each patient. Thanks!
User | Count |
---|---|
93 | |
86 | |
68 | |
62 | |
58 |
User | Count |
---|---|
149 | |
113 | |
95 | |
80 | |
72 |