Forum Discussion
datedif Function, only for working days (mon-Fri)
- 8 years ago
Did you use a disconnected table?
BachFel there is possibly a better way to do this but what i would do is then create a day of week column
Date =
ADDCOLUMNS (
CALENDAR(2015-01-01,2018-01-01),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Day of Week", FORMAT([Date],"dddd"))
then create calculated column that is called IsWorkingDay ( you could do a an if statement too)
IsWorkingDay=
SWITCH (
TRUE (),
'Date'[Day of Week] = "Saturday", 0,
'Date'[Day of Week] = "Sunday", 0,
1
)
then you will need to add the isworkingday to your calculation, not sure what you are working out below, is there a reason you not using the datediff function?
Tage_seit_erster_Objektbegung = if(KontElemente[Datum der Besichtigung]<>BLANK();TODAY()-KontElemente[Datum der Besichtigung].[Date];BLANK())
Thank u so far!
There is no reason for not using the datediff function, I just didn´t know that it´s possible in DAX.
then you will need to add the isworkingday to your calculation, not sure what you are working out below, is there a reason you not using the datediff function?
Tage_seit_erster_Objektbegung = if(KontElemente[Datum der Besichtigung]<>BLANK();TODAY()-KontElemente[Datum der Besichtigung].[Date];BLANK())
I´m trying to show the difference in days between the [Datum der Besichtigung] and today (but only the weekdays). If [Datum der Besichtigung] is empty there should be no calculation. I´m not really sure how to install the isworkingday in the formula..
Would be grateful if u can help me out
- vanessafvg8 years agoCommunity Champion
BachFel not sure if i have captured what you have asked for but give it a go
assuming you have created a date table which is what is required and then created a relationship on that date to the date in your table
Tage_seit_erster_Objektbegung =
IF (
ISBLANK ( datetable[date] ),
BLANK (),
IF ( isworkingday = 1, DATEDIFF ( datetable[date], TODAY (), DAY ), BLANK () )
)- BachFel8 years agoHelper II
Tage_seit_erster_Objektbegung =
IF (
ISBLANK (KontElemente[Datum der Besichtigung]);
BLANK ();
IF (Datumstabelle[AlleDaten]) = 1; DATEDIFF (KontElemente[Datum der Besichtigung]; TODAY (); DAY ); BLANK () )I´m not able to select the table Datumstabelle where the row AlleDaten is in...
I created a relationship as u mentioned but it won´t work.. I´m lost...
- vanessafvg8 years agoCommunity Champion
it looks like the relationship has been created, what error you getting?