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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
frithjof_v
Super User
Super User

Using variable vs. referencing another query

Hi,

 

I am wondering if there is some obvious conceptual difference (which may impact performance) between referencing a variable (i.e. referencing another step in the same query), or referencing the output of another query, when creating a custom column?

 

An example:

 

Let's say I have a very simple table, it's just a list of numbers from 1 to 10 000 000.

I want to add a Timestamp column to this table.

 

Does it make a difference if I reference a variable (step) of the same query:

frithjof_v_0-1720960031571.png

 

let
    Source = List.Numbers(1, 10000000),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    NowVariable = DateTimeZone.UtcNow(),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Timestamp", each NowVariable)
in
    #"Added Custom"

 

 

 

Or if I reference another query:

frithjof_v_0-1720959722762.png

 

let
    Source = List.Numbers(1, 10000000),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Timestamp", each NowQuery)
in
    #"Added Custom"

 

 

The referenced query, NowQuery, is created as simple as this:

 

let
    Source = DateTimeZone.UtcNow()
in
    Source

 

 

 

This is an example, however I am also generally interested in understanding if there is a conceptual difference (performance-wise) between using a variable (a step inside the same query) or using the output of another query? 

2 REPLIES 2
tharunkumarRTK
Super User
Super User

@frithjof_v 
In terms of performance, I think referencing the variable step in the same query would be a better option. Because, each individual query evaulates independently. You can find more information in chirs webb's blog 
https://blog.crossjoin.co.uk/2019/10/13/why-does-power-bi-query-my-data-source-more-than-once/



Need Power BI consultation, hire me on UpWork .


If the post helps please give a thumbs up



If it solves your issue, please accept it as the solution to help the other members find it more quickly.




Tharun



Thanks @tharunkumarRTK,

 

I was thinking something similar.

 

However I tried refreshing the two tables separately in Power BI Desktop, and by looking in SQL Server Profiler it seems the Command End events for both tables had very similar CPUTime and Duration. 

 

frithjof_v_0-1720961486745.png

 

(I'm not sure if the Command Begin and Command End are the most relevant events to track. If anyone have suggestion about which events I should track, please let me know.)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.