Forum Discussion
Calculate positive and Negative WorkingDays
Hello All,
I am new to PowerBI and DAX, So i really need some expereinced suggestions from you all.
I have create Calender Table using Calender Function from
Can any one please help me with this.
Thanks,
Mohan
6 Replies
- amitchandak
Super User
use in a column calculation startofmonth and endofmoth like given below. Do minor adjustment of +1 -1.
datediff(date,startofmonth(date),day)
datediff(endofmonth(date),(date),day)
Also change code use table[column] , where date has been used
Hope it helps.
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin- Mohan221213New Member
Thanks for the reply amitchandak .
I did tried as below by using your suggestions.
I guess i am half way through, but not completely.
First i did created a weekname column by excluding SAT and SUN
WeekName =VAR DayName = FORMAT(Calender[Date],"DDDD")RETURNSWITCH(TRUE(),DayName= "Saturday" || DayName= "Sunday",BLANK(),DayName)After this, i have written below DAX=VAR Days =CALCULATE(COUNT(Calender[Date]),FILTER(ALLEXCEPT(Calender,Calender[Month-Year]),Calender[Date] <= EARLIER(Calender[Date]) &&Calender[WeekName] <> BLANK()))VAR EndMonth = datediff(endofmonth(Calender[Date]),(Calender[Date]),DAY)-1RETURNSWITCH(TRUE(),Days >=1 && Days <=3 && Calender[WeekName] <> BLANK(),Days,EndMonth >=-3 && EndMonth <= -1, EndMonth,BLANK())Which is giving me Positive first three working days right result, but coming to the last three working days, it is not.I did checked for Mar-2018 the result is showing as below.Can you please suggest me how can i correct it.Thanks,Mohan- amitchandak
Super User
Can you share sample data in excel along with the expected results? If possible please share a sample pbix file after removing sensitive information.Thanks.
My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970