Forum Discussion
DAX: relating a field from another table in a function
- 10 years ago
Neuro81 and ankitpatira
Sorry for the trouble, but I managed to fix it in the end
=(YEAR(Today())-YEAR(RELATED('Availability Calendar'[Date])))*12+MONTH(Today())-MONTH(RELATED('Availability Calendar'[Date]))
The problem is that I got lost with the number of parenthesis (how lame!) So I deconstructed the formula and use a replace function to make it work.
Wish I could delete this post altogether. Again sorry for wasting your time! :smileysad::smileymad:
What errors did you get?
also did you create a relationship between the two tables in the diagram view?
Neuro81 There is a relationship, yes. Between the fact table in which the calculated column is located, and a Date Dimension table. The linked fields are called DATEKEY in both tables.
Here is what I tried:
=(YEAR(Today())-YEAR(RELATED('Availability Calendar'[Date]))*12+MONTH(Today())-MONTH(RELATED('Availability Calendar'[Date]))
But Visual Studio gives me a syntax error message.