Ref_Rows() not work as expected

polohi_2-1686558548987.png

I have three tables "Leave History", "Leave", "Employee detail".Where Leave Histroy ref to Leave, Leave ref to Employee detail all using EMP_Email. 

But I want to ref back from Leave to History with Ref_Rows(), instead of giving me the result of History. It gives me employee detail which does not makes sense, or can anyone point out what I was doing wrong?


Here is want I want to achieve, caculate the leave of current month from history  table and insert into current leave table. 

SUM(
SELECT(
Leave History[time_in_hour],
AND(
[EMP_Email] = [Related Leave Historys].[EMP_Email],
MONTH(TODAY()) = MONTH([Related Leave Historys].[date])
)
)
)

 

Solved Solved
0 3 127
1 ACCEPTED SOLUTION

I don't understand your data structure or goal well enough to draft an example. Nonetheless, in what you have so far the basic mistake is that [Related Leave Historys] is not a Ref type column, but rather a list of key values from another table that references its table. You need to distinguish between the following. Note that one uses a dot (.) delimiter and the other does not.

  • Dereference one reference value: [Ref column].[Column from referenced table]
  • Dereference a list of referenced values: [Related... column][Column from referencing table]

View solution in original post

3 REPLIES 3

Thanks for this. I understand the concepts it explain clearly but how to do it if I already have the ref one way and I want to refer backward.

I don't understand your data structure or goal well enough to draft an example. Nonetheless, in what you have so far the basic mistake is that [Related Leave Historys] is not a Ref type column, but rather a list of key values from another table that references its table. You need to distinguish between the following. Note that one uses a dot (.) delimiter and the other does not.

  • Dereference one reference value: [Ref column].[Column from referenced table]
  • Dereference a list of referenced values: [Related... column][Column from referencing table]
Top Labels in this Space