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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
frithjof_v
Community Champion
Community Champion

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.