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?
- pmdci10 years agoAdvocate V
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.
- pmdci10 years agoAdvocate V
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:
- Neuro8110 years agoHelper I
pmdci
Sometimes its best to talk it out.Whenever I get stuck I usually take a walk and try not to think of the problem and a lot of the time the solution just comes.
Its good that you take the time to try and fix the problem yourself instead of just waiting till someone comes to help you!!