Forum Discussion
Access a table directly or through a variable?
wpf_ , Table in the variable will create an in-memory object. So only create it if is needed most.
- wpf_5 years ago
Post Prodigy
amitchandak In a row context, if the measure has a variable that contains the table, does every row query for that table and store it in memory for every row, or does BI just run query once and store it in memory, and each row calls this variable?
If it only runs the query once, then I assume it would be more efficient to store the table in a variable versus just straight query the table for every row?
- amitchandak5 years ago
Super User
wpf_ , Please share the sample formulas. Need to get the exact context of what you are doing with table.
- wpf_5 years ago
Post Prodigy
Here is the code:
=================================================
Assigned Employee=
VAR Employee_Table =
SUMMARIZE(EmployeeTable, EmployeeTable[employeename])
VAR EmployeeReplacement_Table =FILTER(
SUMMARIZE(EmployeePlacementTable,
EmployeePlacementTable[employeeReplacement],
EmployeePlacementTable[replacementName],
EmployeePlacementTable[dateofReplacement],
EmployeePlacementTable[leaverequestNumber]
),
DATEVALUE(EmployeeReplacement_Table[dateofReplacement]) = DATEVALUE([Today Date])
)VAR WhoisWorkingToday=
IF([Employee Working Status] = "Working", MAXX(Employee_Table, Employee_Table[employeename]),
IF([Employee Working Status] = "Not Working", MAXX(FILTER(EmployeeReplacement_Table, EmployeeReplacement_Table[leaverequestNumber] = [Get LeaveRequest Number]), EmployeeReplacement_Table[replacementName])))
return WhoisWorkingToday==========================================
Is it a good idea to place the employeeTable inside a variable or is it better to access the employeeTable directly?