Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
I have a table (vw_WorkCenterUtilization) and a date column (Work_Date) that I need to calculate the oldest and newest date in the data, and the number of work days within it. I'm using the FIRSTDATE and LASTDATE functions in seperate Measures to draw this number, but I do not know how to only include the number of work days in the range. My current code to calculate the days different is as follows
Days = DATEDIFF([OldestDate],[NewestDate],DAY)
How would I go about getting this info if there is no NETWORKDAYS function like their is in Excel? Attached is my current output in screenshot as well. I beleive the number I'm looking for should be 261 days, not 365.
Thank you!
Solved! Go to Solution.
Hi @kyleldi,
Firstly, create a calendar table in Power BI Desktop following the guide in this blog. Then create a column in the calendar table using the Dax below.
is work day = SWITCH(WEEKDAY([Date]),1,0,7,0,1)
Secondly, create a measure using the following DAX and create a card visual.
Days= CALCULATE(SUM('Date'[is work day]), DATESBETWEEN('Date'[Date], [OldestDate], [NewestDate] ))
Thanks,
Lydia Zhang
Maybe its old topic but easises solution is to create a custom function lik this:
(StartDate as date, EndDate as date) as number =>
let
DateList = List.Dates(StartDate, Number.FromText(EndDate-StartDate), #duration(1,0,0,0)),
RemoveWeekdns = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday)<5),
CountDays = List.Count(RemoveWeekdns)
in
CountDays
And then just invoke it whenever needed.
They also just added NETWORKDAYS in DAX this month.
https://docs.microsoft.com/en-us/dax/networkdays-dax
Hi,
I have this formula
Do I have to update my version of desktop to get this? im running 2.105
I am trying to computer network days between two dates.
I tried:
Hi,
Does this work?
Days = COUNTROWS(FILTER(CALENDAR(min(ReceivingLog[Receipt Date]),max(ReceivingLog[Inspection Date])),WEEKDAY([Date],2)<=5))
The issue is the Month formula requires an integer value it can't convert the text based month i.e. January. You can try a new column that converts the months to a value something like IF(MyMonth - "Januaury", 1, IF(MyMonth = "Februaury", 2 ... etc.
Do I add that column to my table [ReceivingLog]? or do I click Add data and create a table with one column [MonthNumber}?
Yes, but I just looked at your formula again and see you are taking year, month, and day from a date field. If ReceivingLog[Receipt Date] is formated then you don't need to put it in a DATE formula i.e. COUNTAX(FILTER(ReceivingLog,ReceivingLog[Receipt Date]=>...
I found an easier solution one column and one measure, but it could be a column if you don't need it to be dynamic.
Column
Weekday = WEEKDAY(WEEKDAY(MyTable[MyDate],2)) Note: the 2 at the end makes it Monday 1 - Sunday 7
Measure
NetWorkDays = COUNTAX(FILTER(MyTable,AND(MyTable[MyDate]>= MyTable[MyStartDate], MyTable[Weekday]<6)), MyTable[MyDate]) - COUNTAX(FILTER(MyTable,AND(MyTable[MyDate]> MyTable[MyEndDate], MyTable[Weekday]<6)), MyTable[MyDate]) Note: this is counting all weekdays after the start date and then subtracting all weekdays after the end date.
If you needed to deal with holidays it would be pretty simple as well, just add a new column to indicate Holidays or even a seperate holiday date table and you can use that to filter out the holidays from your count.
Hi @kyleldi,
Firstly, create a calendar table in Power BI Desktop following the guide in this blog. Then create a column in the calendar table using the Dax below.
is work day = SWITCH(WEEKDAY([Date]),1,0,7,0,1)
Secondly, create a measure using the following DAX and create a card visual.
Days= CALCULATE(SUM('Date'[is work day]), DATESBETWEEN('Date'[Date], [OldestDate], [NewestDate] ))
Thanks,
Lydia Zhang
Hi @v-yuezhe-msft ,
I want Values Row by row in Calculated column followed same way as you mentioned below and it is not giving me negtive values,Please find the Below Data whichi have and Screen Captures.
Thanks In Advance.
Dax Formula:
@v-yuezhe-msft - hello, I tried this but it errored about because there are instances of nulls in my oldest date and newest date. Is there a way to handle that?
Hi,
When I try to create the measure (last step of your instructions) i get an error message: "A single value for column 'Total Revenue' in table 'SalesData' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."
Ho wdo i resolve that? Also are we meant to create a relationship with the Date/Calendar Table and the table containing our start and end dates?
This looks fine, how to get number of hours as well, so times tickets open on same day and closed on same day. the mentioned formula get 1 day for this as well. but wanted to claculate hours in this scenario.
Thanks,
Thimma
Hi,
I want to calculate Network days between Created Date to Till Date, My date filed looks like,
How can we Calculate, If i am tring the above Dax calculation it is geving the error. calculation is,
is work day = SWITCH(WEEKDAY([Created Date]),1,0,7,0,1)
NetworkDays = CALCULATE(SUM([is work day]),
DATESBETWEEN([Created Date].[Date],Sheet1[Created Date],TODAY()
))
Open Request = IF(AND('Fusion dashboard report'[Completion Status]="Open", [Status]="MDM Ops Review - Undelete"),'Fusion dashboard report'[Network days], -1)
While i am using this Calculation it showing the below error.
A circular dependency was detected: Fusion dashboard report[Network days], Fusion dashboard report[Open - FLS / Requestor in Days], Fusion dashboard report[Network days].
please help me on this.
Thanks in Advance.
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |