Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
wpf_
Post Prodigy
Post Prodigy

Access a table directly or through a variable?

I have a table that holds a list of employees.  In one of my measures I want to get the employee name using the maxx function.  As far as efficiency, is it better to save the the employee table in a variable first, then access the table from within the same measure, or is it better to access the employee table without using a variable?  Thanks. 

4 REPLIES 4
amitchandak
Super User
Super User

@wpf_ , Table in the variable will create an in-memory object. So only create it if is needed most.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@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?  

@wpf_ , Please share the sample formulas. Need to get the exact context of what you are doing with table. 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

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?

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors