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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Facing problem weekends count while substracting from Total days count of the month

Hello All,

I am new to Power BI. I am preapring dashboard for Overtime calculation.
I am having huge data and i am able to display full month data without error because there i am just add few columns and displaying Total Overtime.
But when it comes to Current month or partial month data then i am need to calculate Estimated Overtime for remaining working days excluding saturdays.
Sample of Excel is,

 
DateIDActualTimeHolidayOvertimeInTime
 
OutTime
2019060119970370000
2019060219970370000
2019060319970374.208031845
2019060419970373.408031744
2019060519970373.708031753
2019060619970374.608231911
2019060719970374.208212011
2019060819970370000
2019060919970370000
2019061019970374.608231826
2019061119970373.208221734
201906121997037008232043
2019061319970374.108222049
2019061419970374.208361800
2019061519970370000


I have imported this excel file to PowerBI and it created Excel name as Table name.
Then i have created Calendar table for calculating total weekends count.
I have created two calculated columns for calculating Saturdays in month and Sundays in month.
Measure is >> WeekendsInMonth = SUMX('Calendar', 'Calendar'[SaturadaysInMonth] + 'Calendar'[SundaysInMonth] )
WeekendsInMonth column is having count of weekends in each month.
Then i have created few Measures and Calculated columns for Getting Worked days count of the month, Total Overtime, Holidays, Worked average overtime etc in Excel Table.
TotalOvertime (Measure) = SUMX('sample', 'sample'[ActualOvertime] + 'sample'[HolidaysOvertime] )
WkdDaysOfMonth (Calculated column)= IF('sample'[InTime]<>0 && 'sample'[OutTime]<>0, 1 , 0)
WrkdAvgOvertime (Measure)= DIVIDE('sample'[TotalOvertime]/ SUM('sample'[WkdDaysOfMonth ]))
TotalDaysInMonth (Measure)= TotalDaysInMonth = DAY(ENDOFMONTH('Calendar'[Date].[Date]))
TotalHolidays (Measure) = Here i am adding Employee taken leaves and Company Holidays and both are calculated columns
EstdWkgDaysOfMonth (Measure) = 'sample'[TotalDaysInMonth ] - SUMX('sample', 'sample'[WkdDaysOfMonth] + 'sample'[WeekendsInMonth] + 'sample'[TotalHolidays])
EstdWorkingOvertime (Measure) = 'sample'[EstdWkgDaysOfMonth] * 'sample'[WrkdAvgOvertime ]

Excel file has Date column which is type of Number then i have created new Calculated column for as below,
FormattedDate = IFERROR( DATE(LEFT('sample'[Date],4),MID('sample'[Date],5,2),RIGHT('sample'[Date],2)), DATE("yyyy","mm","dd"))

Then i have given relationship as Many-to-one in Model view.

For Full month data i am just showing TotalOvertime in Stacked bar.
For partial month i am showing TotalOvertime in Blue bar and remaining estimated overtime in Orange bar.
But this remaining estimated overtime i am showing properly but it contains saturdays and sundays count. I am trying to show only reamining working days excluding weekends.
i thing here it is considering weekends count for data the data present in excel file. It is taking whole weekends count in month.
I have shown in image below,

Initial.pngJuneView.pngMayView.png

I have explained error and description in image also.

I think it is considering weekends count upto the date present in the Excel file. So how can i remove total weekends count from remaining working days.
Kindly help me on this issue.

 

Regards,

Amar

1 REPLY 1
Greg_Deckler
Super User
Super User

Perhaps this will help: https://community.powerbi.com/t5/Quick-Measures-Gallery/Net-Work-Days/td-p/367362



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.