Forum Discussion
direct application of WORKDAY function like in excel
Hello,
May I know how to create WORKDAY function in powerBI with DAX function? I have no holidays to add. I have a column with dates and another column with numerics. I just wanted to get the result in new column with the workday by adding numeric to my existing column. Is there a way to do it directly without any additional tables please?
Anonymous wrote:
Dear Phil_Seamark
Thanks for the response.
In your syntax, i couldn't figure out where to key in my customized day to add for each row.
I have attached my sample data. Column C is my requirement. Could you please have a look?
Thanks in advance!
Anonymous
You can create an calendar table as below
dimdate = VAR onlyWorkdays = FILTER ( CALENDAR ( "2017-01-01", "2017-12-31" ), WEEKDAY ( [Date] ) <> 1 && WEEKDAY ( [Date] ) <> 7 ) RETURN ADDCOLUMNS ( onlyWorkdays, "Index", RANKX ( onlyWorkdays, [Date],, ASC, DENSE ) )Then connect your source table to the calendar table, create a measure as
exw date = VAR DateIndex = MAX ( dimdate[Index] ) VAR LeadTime = MAX ( 'Table'[Lead Time] ) RETURN MAXX ( FILTER ( ALL ( dimdate ), dimdate[Index] = DateIndex + LeadTime ), dimdate[Date] )See more details in the pbix file.
Hi Anonymous
This is one way to do it as a calculated column. Just replace Table3 with your own tablename
exw date = VAR myDate = ADDCOLUMNS(FILTER(CALENDAR(Table3[Order Date],TODAY()),WEEKDAY([Date],3)<5),"Days",1) VAR Cumulative = ADDCOLUMNS( myDate, "D", SUMX(filter(myDate,[Date]<EARLIER([Date])),[Days]) ) RETURN MINX(FILTER(Cumulative,[D]='Table3'[Lead Time]),[Date])
13 Replies
- Phil_Seamark
Microsoft Employee
Hi Anonymous
You could try adding this calculated column to your date table
WORKDAY = SWITCH( WEEKDAY([Date],1), -- Is Sunday -- 7,0, -- Is Saturday -- 1,0, -- Else -- 1 )- AnonymousNot applicable
Dear Phil_Seamark
Thanks for the response.
In your syntax, i couldn't figure out where to key in my customized day to add for each row.
I have attached my sample data. Column C is my requirement. Could you please have a look?
Thanks in advance!
- Eric_Zhang
Microsoft Employee
Anonymous wrote:
Dear Phil_Seamark
Thanks for the response.
In your syntax, i couldn't figure out where to key in my customized day to add for each row.
I have attached my sample data. Column C is my requirement. Could you please have a look?
Thanks in advance!
Anonymous
You can create an calendar table as below
dimdate = VAR onlyWorkdays = FILTER ( CALENDAR ( "2017-01-01", "2017-12-31" ), WEEKDAY ( [Date] ) <> 1 && WEEKDAY ( [Date] ) <> 7 ) RETURN ADDCOLUMNS ( onlyWorkdays, "Index", RANKX ( onlyWorkdays, [Date],, ASC, DENSE ) )Then connect your source table to the calendar table, create a measure as
exw date = VAR DateIndex = MAX ( dimdate[Index] ) VAR LeadTime = MAX ( 'Table'[Lead Time] ) RETURN MAXX ( FILTER ( ALL ( dimdate ), dimdate[Index] = DateIndex + LeadTime ), dimdate[Date] )See more details in the pbix file.