Forum Discussion
Function Related doesn't seem to work
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
- RonaldvdH2 years agoPost Patron
isjoycewang thanks for responding but i was workin on my formula a bit more. Could you recheck my post seeing i've altered the formula and my initial post
- isjoycewang2 years agoSolution Supplier
RELATED() should be able to apply in the SWITCH() function.
Please create a table containing columns from 'Date' and 'Tickets' table to see if they have valid relationship. If not, please try to change column data type or check settings to make them connected.
Another way is to use LOOKUPVALUE() function to get the 'Date'[ServiceWindow] value as you used in the VAR LaatsteDagVerstrekenTijd. Does it work for you? Thanks.
- RonaldvdH2 years agoPost Patron
isjoycewang if I change the first part of the formula from Related to LookupValue the result is the same. So the formula doesn't work because it just can't find the correct value for ServiceWindow in the Date table and just returns 0 every time.
I already have a summarized table based on both Tables called Tickets. It summarizes the table based on Ticket ID's and then uses this formula to copy the StartDate and EndDate as wel as StartTijd and Eindtijd and that works
StartDate = VAR __Tickets = Tickets[WMS_ID] VAR __Incidenten = FILTER(ALL('Incidenten'),'Incidenten'[WMS_ID] = __Tickets) RETURN MAXX(__incidenten,[StartDate])
- RonaldvdH2 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