Forum Discussion
RonaldvdH
2 years agoPost Patron
Function Related doesn't seem to work
Hey guys, Im working on a formula that calculates the amount of hours between 2 dates based on working days. I've been wachting a clip on how to do that and i'm using this formula Doorloopt...
isjoycewang
2 years agoSolution Supplier
Hi,
There are multiple VAR in your formula but in fact they're not working in the final result.
The only one impacts your result is below:
VAR EersteDagVerstrekenTijd = Switch(TRUE(),
RELATED('Date'[ServiceWindow])=0,0)
Return EersteDagVerstrekenTijd
In this DAX, it describes that if Related('Date'[ServiceWindow]) = 0, your result would be zero; otherwise it'll be BLANK() due to no definition.
What's your expected result? If you expect that if the Related('Date'[ServiceWindow]) = 1, then you could get 1 in the 'Tickets' table, please try below:
Doorlooptijd =
//VAR ServiceWindowStart = Calculate(SELECTEDVALUE(ServiceWindow[ServiceWindow]),ServiceWindow[Dag]="Start")
//VAR ServiceWindowEind = Calculate(SELECTEDVALUE(ServiceWindow[ServiceWindow]),ServiceWindow[Dag]="Eind")
//VAR ServiceWindowPerDag = VALUE(ServiceWindowEind-ServiceWindowStart)*24
//VAR DezeStartDatum = [StartDate]
VAR EersteDagVerstrekenTijd = Switch(TRUE(),
RELATED('Date'[ServiceWindow])=0,0,1)
Return EersteDagVerstrekenTijd
Best Regards,
Joyce
RonaldvdH
2 years agoPost Patron
isjoycewang the expected result is that it checks the value for ServiceWindow for that specific date in the (related) date table.
If it returns 0 then that date isn't in the servicewindow and if it returns a 1 then it IS in the servicewindow