Forum Discussion
Create a time sensitive matrix using measure
Nabil_DS ,
First, calculate the attendance rate by dividing the number of attended sessions by the total sessions. Use this DAX formula:
Attendance Rate =
DIVIDE(
CALCULATE(COUNTROWS('Session'), 'Session'[Session Status] = "Attended"),
COUNTROWS('Session'),
0
)
Next, calculate the unique attendees per company by counting the distinct representatives who attended at least one session. Use this DAX formula:
Unique Attendees Per Company =
CALCULATE(
DISTINCTCOUNT('Session'[Client Representative]),
'Session'[Session Status] = "Attended"
)
Then, calculate the minimum and maximum values for attendance rates and unique attendees across all companies to determine their ranges. For the attendance rate:
Min Attendance Rate =
MINX(ALL('Session'[Client Name]), [Attendance Rate])
Max Attendance Rate =
MAXX(ALL('Session'[Client Name]), [Attendance Rate])
For unique attendees:
Min Unique Attendees =
MINX(
VALUES('Session'[Client Name]),
CALCULATE(
DISTINCTCOUNT('Session'[Client Representative]),
'Session'[Session Status] = "Attended"
)
)
Max Unique Attendees =
MAXX(
VALUES('Session'[Client Name]),
CALCULATE(
DISTINCTCOUNT('Session'[Client Representative]),
'Session'[Session Status] = "Attended"
)
)
Next, calculate the range for each metric and divide it by five to determine the bucket intervals. For attendance rates:
Attendance Rate Range =
[Max Attendance Rate] - [Min Attendance Rate]
Bucket Interval =
DIVIDE([Attendance Rate Range], 5)
Next, calculate the range for each metric and divide it by five to determine the bucket intervals. For attendance rates:
Attendance Rate Range =
[Max Attendance Rate] - [Min Attendance Rate]
Bucket Interval =
DIVIDE([Attendance Rate Range], 5)
For unique attendees:
Unique Attendees Range =
[Max Unique Attendees] - [Min Unique Attendees]
Unique Attendees Bucket Interval =
DIVIDE([Unique Attendees Range], 5)
Finally, assign each company to a bucket based on their attendance rate or unique attendee count. For attendance rate:
Attendance Rate Bucket =
VAR CurrentRate = [Attendance Rate]
VAR MinRate = [Min Attendance Rate]
VAR Interval = IF([Bucket Interval] > 0, [Bucket Interval], 1)
RETURN
IF(
CurrentRate < MinRate,
1,
CEILING(DIVIDE(CurrentRate - MinRate, Interval), 1)
)
For unique attendees:
Unique Attendees Bucket =
VAR CurrentAttendees =
CALCULATE(
DISTINCTCOUNT('Session'[Client Representative]),
'Session'[Session Status] = "Attended"
)
VAR MinAttendees = [Min Unique Attendees]
VAR Interval = IF([Unique Attendees Bucket Interval] > 0, [Unique Attendees Bucket Interval], 1)
RETURN
IF(
CurrentAttendees < MinAttendees,
1,
CEILING(DIVIDE(CurrentAttendees - MinAttendees, Interval), 1)
)
These steps and formulas ensure dynamic bucketing, handling edge cases like zero intervals or values below the minimum boundary.
The resulting output is as shown below:
To address your requirement for a time-sensitive measure, you can include a date field in your analysis and establish a relationship with the calendar table. This will ensure that the calculation aligns with the time dimension filter.
I have attached an example pbix file for your reference.
Best regards,
- Nabil_DS1 year agoNew Member
Thanks a lot DataNinja777
I have already created the measures but the output I want is something else; I want a matrix where rows represent weighted attendance rate segments and columns represent the unique attendee segments Weighted Attendance Rate Segments
Weighted attendance segments
0-100 attendees
100-200 attendees
200-300 attendees
300-400 attendees
0-25
5
8
33
77
25-50
2
5
12
18
50-75
3
3
6
32
75-100
7
9
2
54