Forum Discussion
Lookup Date in one table, return value from another; Direct Import
- 3 years ago
If you are looking for a measure DAX syntax, add this measure to your Expense Data table.
Total Hours by Type Absence = var _curValue = CALCULATE( SUM('Time Data'[ Hours ]), FILTER( 'Time Data', 'Time Data'[EmpID] = SELECTEDVALUE('Expense Data'[EmpID]) && 'Time Data'[Date] = SELECTEDVALUE('Expense Data'[Date]) && 'Time Data'[ Type ] = " Absence" )) RETURN IF ( HASONEVALUE('Expense Data'[EmpID]) && HASONEVALUE('Expense Data'[Date]) , IF (ISBlank(_curValue), 0, _curValue) , BLANK())Adjust the formula, I see / got spaces when I copy pasted your sample data.
Hope it helps!
Since you said that it is SQL tables direct query, you can do this
a) Check the Dax if you have missed any logic
b) Review the code generated
- Go to optimize tax and click Performance Analyzer
- Create a page with only the table visual from all columns and measures from 'Expense Data'
- Click refresh visual
- Copy query and paste into notepad
- It contains both DAX and SQL. See where it is going wrong.
Note: We cannot change this generated query. but gives you where it is going wrong!
Roughly it genarates as below:
I verified my own set of tables and works fine the DAX, using Direct Query and two tables scenario.
Here is the code generated -- I marked the "new" column that pulls from the hours table in blue. The issue I see is that I don't have reference to SQL...
- ssbagley3 years agoHelper III
Ignore my previous message - I started a new file from scratch and it worked beautifully! I cannot thank you enough for your help!
- sevenhills3 years agoSuper User
Glad to hear that it worked!