Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi There
How to calculate number of days in a week, like,
I have attendance Table in which i want to calculate for how many days students are present for that week, Week1,2,3,4,5
in 1st week, how many students are present for 1 day,2days,3days,4 days,5 days
Solved! Go to Solution.
Hi @Sunilkulkarni ,
Please try the following methods and check if they can solve your problem:
1.Create the simple table.
2.Using the week num and week day to create the new column.
weeknumber = WEEKNUM('student present'[Date],2)
weekday = WEEKDAY('student present'[Date],2)
3.Create the measure to calculate student.
student present = CALCULATE(
COUNTROWS('student present'),
FILTER(
'student present', 'student present'[IsPresent] = True
)
)
4.Drag the week number into the Rows, drag the weekday into the Columns and drag the measure into the matrix visual values.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Sunilkulkarni ,
Please try the following methods and check if they can solve your problem:
1.Create the simple table.
2.Using the week num and week day to create the new column.
weeknumber = WEEKNUM('student present'[Date],2)
weekday = WEEKDAY('student present'[Date],2)
3.Create the measure to calculate student.
student present = CALCULATE(
COUNTROWS('student present'),
FILTER(
'student present', 'student present'[IsPresent] = True
)
)
4.Drag the week number into the Rows, drag the weekday into the Columns and drag the measure into the matrix visual values.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
To calculate the number of days each student is present in a given week, you can follow these steps using DAX (Data Analysis Expressions) in Power BI or Excel:
Assuming you have a table named Attendance with columns StudentID, Date, and any other relevant columns.
Create a calculated column to extract the week number from the date. Let's name it WeekNumber.
WeekNumber = WEEKNUM('Attendance'[Date])
Now, you can create a measure to count the number of days each student is present in each week.
DaysPresent =
CALCULATE(
COUNTROWS('Attendance'),
FILTER(
'Attendance',
'Attendance'[Presence] = "Present" && 'Attendance'[WeekNumber] = SELECTEDVALUE('Attendance'[WeekNumber])
)
)
In this measure:
This measure will give you the count of days each student is present in the selected week. You can slice and dice the data by student and week to get the desired analysis. Make sure to replace 'Attendance', 'Presence', and other column names with the actual names from your data model.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Thanks for the suggestion, will try this,
Im not selecting any week No. but i want to represnt in the Stacked bar chart, below Num are no. of students present
Week | 1Day | 2 Days | 3 Days | 4Days | 5Days |
1 | 10 | 35 | 30 | 45 | 10 |
2 | |||||
3 | |||||
4 |
To represent the number of students present for each day of the week in a stacked bar chart in Power BI, you can follow these steps:
Create a New Measure for Each Day: You need to create a separate measure for each day of the week (1 Day, 2 Days, 3 Days, 4 Days, 5 Days) that calculates the count of students present for that specific number of days.
Here is an example of how you can create a measure for the count of students present for 1 day:
StudentsPresent_1Day = CALCULATE(COUNTROWS(Attendance), Attendance[WeekNumber] = SELECTEDVALUE(Attendance[Week]) && Attendance[DaysPresent] = 1)
You should create similar measures for 2 Days, 3 Days, 4 Days, and 5 Days, replacing the condition Attendance[DaysPresent] = 1 with the appropriate conditions for each measure.
Create a Stacked Bar Chart: Once you have created the measures for each day, you can create a stacked bar chart with the following settings:
Format the Chart: You can format the chart to make it more readable and visually appealing. You may want to adjust the colors, add data labels, and provide a suitable chart title and axis labels.
By following these steps, you should be able to create a stacked bar chart in Power BI that represents the number of students present for each day of the week across different weeks. Adjust the measures and chart settings based on your specific data structure and requirements.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
13 | |
12 | |
10 | |
7 | |
7 |
User | Count |
---|---|
18 | |
14 | |
11 | |
11 | |
10 |