Forum Discussion
Measure for Group by matrix value
Hi all,
I hit the wall while creating a matrix using measure value. This is the senario. I have a staff schedule data table. From there, I created 4 measures - active scheudle, attended schedule, pecentage, percentage group as shown below.
1. Active Shifts = CALCULATE(COUNTROWS(Staff_Schedule), Staff_Schedule[ActiveSchedule] = "Yes")
2. Attended Shifts = CALCULATE(COUNTROWS(Staff_Schedule), (Staff_Schedule[ArrivalStatus] = "On Time" || Staff_Schedule[ArrivalStatus] = "Late Arrival"), Staff_Schedule[ActiveSchedule] = "Yes")
3. Percentage = ROUND([Attended Shifts]/[Active Shifts]*100,0)
4. Percentage Group =
SWITCH(TRUE,
[Percentage] <=20, "0-20",
[Percentage] >=21 && [Percentage] <= 40, "21-40",
[Percentage] >=41 && [Percentage] <= 60, "41-60",
[Percentage] >=61 && [Percentage] <= 80, "61-80",
[Percentage] >=81 && [Percentage] <= 100, "81-100"
)
This is the matrix created with the measures.
This is the visual setting. * EmplolyeeID is a column from the staff schedule data table.
I need to count the rows of Percentage Group by each pecentage group (e.g. 0-20, 21-40....), and make a matrix like this with the counts.
Anyone has an idea?
Thanks!
Eliot
- Anonymous2 years ago
Hi Anonymous
Here is my testing.
My sample:
Create a measure as follows
SUM = VAR _sum = SUMMARIZE(ALL(Staff_Schedule), Staff_Schedule[employeeID], "per", [Percentage Group]) RETURN COUNTX(FILTER(_sum, [Percentage Group] = MAX('Table'[Percentage Group])), [employeeID])Is this the result you expect?
If I've misunderstood you, please provide detailed sample data: How to provide sample data in the Power BI Forum - Microsoft Fabric Community .Please remove any sensitive data in advance.
Best Regards,
Community Support Team _Yuliax - Anonymous2 years ago
Hi Anonymous
You can follow these steps:
Best Regards,
Community Support Team _Yuliax
9 Replies
- gmsambornSuper User
Hi Anonymous
Would it be possible to show some sample data for 'Staff_Schedule' as well as the expected results for that sample data?
- AnonymousNot applicable
The second post is to your quesion.
- gmsambornSuper User
Can you show the following?
1) Please provide sample data that covers your issue or question completely.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...2) Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/14475233) Please explain how you would expect to get from step 1 to 2.
4) If possible, please show your past attempts at a solution.
I hope this helps.
- AnonymousNot applicable
Hi gmsamborn
The "Staff_Schedule" has columns such as Employee ID, Schedule Date, Shift, First Name, Last Name, Check-in time, Check-out time, Arrival Status, Departure Status, and so on. Each row stores one distinct scheudle but each employee can have mutiple schedules (rows). What I am trying to achieve is 1) pulling the attendance percentage of each employee ([Attended Shifts]/[Active Shifts]*100), 2) categorize the percentage into 5 categories 0-20, 21-40, 41-60, 61-80, 81-100, and 3) count how many numbers are within each category. As shown above, I was able to achieve 1) & 2) but not 3).
3) should look like this
Thank you so much!
Eliot
- AnonymousNot applicable
Hi Anonymous
Here is my testing.
My sample:
Create a measure as follows
SUM = VAR _sum = SUMMARIZE(ALL(Staff_Schedule), Staff_Schedule[employeeID], "per", [Percentage Group]) RETURN COUNTX(FILTER(_sum, [Percentage Group] = MAX('Table'[Percentage Group])), [employeeID])Is this the result you expect?
If I've misunderstood you, please provide detailed sample data: How to provide sample data in the Power BI Forum - Microsoft Fabric Community .Please remove any sensitive data in advance.
Best Regards,
Community Support Team _Yuliax- AnonymousNot applicable
Thank you so much Anonymous !! It works perfect! You're my life saver 🙂
Just one thing you might be able to help! This is the clustered column chart I created. Do you know how to make the x-axis order "0-20", "21-40", "41-60", "61-80", "81-100"?
Thanks!
Eliot
- AnonymousNot applicable
Hi Anonymous
You can follow these steps:
Best Regards,
Community Support Team _Yuliax