Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet 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
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 (
Enrollment | Client | Household | EnrollmentDate | FirstEnrollmentClient | FirstEnrollmentHousehold |
100002 | 1235 | 1235 | 1/1/2020 | First Enrollment | First Enrollment |
100000 | 1234 | 1234 | 2/1/2020 | First Enrollment | First Enrollment |
100003 | 1236 | 1236 | 5/1/2020 | First Enrollment | First Enrollment |
100004 | 1237 | 1236 | 5/1/2020 | First Enrollment | First Enrollment |
100005 | 1238 | 1236 | 5/1/2020 | First Enrollment | First Enrollment |
100001 | 1234 | 1234 | 8/1/2020 | Not First Enrollment | Not First Enrollment |
100006 | 1236 | 1236 | 10/4/2021 | Not First Enrollment | Not First Enrollment |
100007 | 1237 | 1236 | 10/4/2021 | Not First Enrollment | Not First Enrollment |
100008 | 1238 | 1236 | 10/4/2021 | Not First Enrollment | Not 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!
Solved! Go to Solution.
Hi @heatherkw ,
You can try this method:
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 @heatherkw ,
You can try this method:
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. 😞
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
86 | |
82 | |
70 | |
49 |
User | Count |
---|---|
143 | |
123 | |
107 | |
61 | |
55 |