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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
heatherkw
Helper I
Helper I

Calculate percent of distinct clients that experienced their first enrollment during a timeframe

I have been trying to make this work for hours and there is I think just one step somewhere that I seem to be missing. In our data, we have enrollments, clients, and households - households have multiple clients, and clients have multiple enrollments. We have unique ids at all of these levels. I am trying to display in a bar graph the percent of enrollments, clients, and households that experienced an enrollment for the first time during whatever time frame the user chooses using a slicer. Right now, the bar graph works perfectly when I look at the enrollment level, but then things get weird when I look at the client and household levels.

I used this to calculate the client's first enrollment date:

FirstEnrollmentCl = CALCULATE (

MIN('Enrollment'[EnrollmentEntryDate]),
ALLEXCEPT ('Enrollment','Enrollment'[PersonalID]))
 
Then I used this to return the percentages for the bar graph:
FirstEnrollClSelect = IF('Enrollment'[FirstEnrollmentCl]= 'Enrollment'[EnrollmentEntryDate], "First Enrollment","Not First Enrollment")
 
So again, at the enrollment level, this works beautifully, but what is happening at the client level is that a client with more than one enrollment is being counted twice, once in the first enrollment count, and again in the not first enrollment count. So I need a way to determine the MAX value essentially for the client during the timeframe based on a slicer - if they had a first enrollment during the timeframe chosen at all, then they would be counted in the first enrollment category, otherwise in the not first enrollment category. Totals should equal the distinct count of clients.
 
Here is sample data and what I need the results to be like:
EnrollmentClientHouseholdEnrollmentDateFirstEnrollmentClientFirstEnrollmentHousehold
100002123512351/1/2020First EnrollmentFirst Enrollment
100000123412342/1/2020First EnrollmentFirst Enrollment
100003123612365/1/2020First EnrollmentFirst Enrollment
100004123712365/1/2020First EnrollmentFirst Enrollment
100005123812365/1/2020First EnrollmentFirst Enrollment
100001123412348/1/2020Not First EnrollmentNot First Enrollment
1000061236123610/4/2021Not First EnrollmentNot First Enrollment
1000071237123610/4/2021Not First EnrollmentNot First Enrollment
1000081238123610/4/2021Not First EnrollmentNot First Enrollment

If I'm looking at enrollments between say 5/1/2020 and 10/31/2021, the results would need to be:

7 distinct enrollments, 3 first time (43%)

4 distinct clients, 3 had first time enrollments (75%)

2 distinct households, 1 had a first time enrollment (50%)

I think I've been staring at this for too long and my mind has gone all over the place. I'm sure I'm missing something obvious. 

Thanks!

1 ACCEPTED SOLUTION
v-yinliw-msft
Community Support
Community Support

Hi @heatherkw ,

 

You can try this method:

vyinliwmsft_0-1666253374252.png

Measure:

Ques 1 Total =
CALCULATE (
    COUNT ( 'Sample Table'[Client] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
    )
)
Ques 1 First En =
CALCULATE (
    COUNT ( 'Sample Table'[Client] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
            && 'Sample Table'[FirstEnrollmentClient] = "First Enrollment"
    )
)
Ques 1 per =
VAR _divide =
    DIVIDE ( [Ques 1 First En], [Ques 1 Total] )
RETURN
    FORMAT ( _divide, "Percent" )
Ques 2 Total =
CALCULATE (
    DISTINCTCOUNT ( 'Sample Table'[Client] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
    )
)
Ques 2 First En =
CALCULATE (
    COUNT ( 'Sample Table'[FirstEnrollmentClient] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
            && 'Sample Table'[FirstEnrollmentClient] = "First Enrollment"
    )
)
Ques 2 per =
VAR _divide2 =
    DIVIDE ( [Ques 2 First En], [Ques 2 Total] )
RETURN
    FORMAT ( _divide2, "Percent" )
Ques 3 Total =
CALCULATE (
    DISTINCTCOUNT ( 'Sample Table'[Household] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
    )
)

 New Table:

Ques 3 table =
SUMMARIZE (
    'Sample Table',
    'Sample Table'[Household],
    'Sample Table'[EnrollmentDate],
    'Sample Table'[FirstEnrollmentHousehold]
)

New Measure:

Ques 3 First En =
CALCULATE (
    COUNT ( 'Ques 3 table'[Household] ),
    FILTER (
        'Ques 3 table',
        MONTH ( 'Ques 3 table'[EnrollmentDate] ) < 11
            && MONTH ( 'Ques 3 table'[EnrollmentDate] ) > 4
            && 'Ques 3 table'[FirstEnrollmentHousehold] = "First Enrollment"
    )
)
Ques 3 per =
VAR _divide3 =
    DIVIDE ( [Ques 3 First En], [Ques 3 Total] )
RETURN
    FORMAT ( _divide3, "Percent" )

 

Is it what you expect?

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yinliw-msft
Community Support
Community Support

Hi @heatherkw ,

 

You can try this method:

vyinliwmsft_0-1666253374252.png

Measure:

Ques 1 Total =
CALCULATE (
    COUNT ( 'Sample Table'[Client] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
    )
)
Ques 1 First En =
CALCULATE (
    COUNT ( 'Sample Table'[Client] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
            && 'Sample Table'[FirstEnrollmentClient] = "First Enrollment"
    )
)
Ques 1 per =
VAR _divide =
    DIVIDE ( [Ques 1 First En], [Ques 1 Total] )
RETURN
    FORMAT ( _divide, "Percent" )
Ques 2 Total =
CALCULATE (
    DISTINCTCOUNT ( 'Sample Table'[Client] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
    )
)
Ques 2 First En =
CALCULATE (
    COUNT ( 'Sample Table'[FirstEnrollmentClient] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
            && 'Sample Table'[FirstEnrollmentClient] = "First Enrollment"
    )
)
Ques 2 per =
VAR _divide2 =
    DIVIDE ( [Ques 2 First En], [Ques 2 Total] )
RETURN
    FORMAT ( _divide2, "Percent" )
Ques 3 Total =
CALCULATE (
    DISTINCTCOUNT ( 'Sample Table'[Household] ),
    FILTER (
        'Sample Table',
        MONTH ( 'Sample Table'[EnrollmentDate] ) < 11
            && MONTH ( 'Sample Table'[EnrollmentDate] ) > 4
    )
)

 New Table:

Ques 3 table =
SUMMARIZE (
    'Sample Table',
    'Sample Table'[Household],
    'Sample Table'[EnrollmentDate],
    'Sample Table'[FirstEnrollmentHousehold]
)

New Measure:

Ques 3 First En =
CALCULATE (
    COUNT ( 'Ques 3 table'[Household] ),
    FILTER (
        'Ques 3 table',
        MONTH ( 'Ques 3 table'[EnrollmentDate] ) < 11
            && MONTH ( 'Ques 3 table'[EnrollmentDate] ) > 4
            && 'Ques 3 table'[FirstEnrollmentHousehold] = "First Enrollment"
    )
)
Ques 3 per =
VAR _divide3 =
    DIVIDE ( [Ques 3 First En], [Ques 3 Total] )
RETURN
    FORMAT ( _divide3, "Percent" )

 

Is it what you expect?

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi there, thanks for this. This still doesn't get me what I need unfortunately. I need to be able to show a bar graph that has the percent where first enrollment = yes AND the percent where first enrollment = NO. Since clients have multiple enrollments, the calculations I have tried have duplicated the client count for NO since they also have enrollments that aren't their first ones. Someone else also tried to help and their suggestions were very similar to this and didn't work the way I needed. 😞

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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