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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How do I have a query reference itself from a previous step (but I don't want to create a new query)

I have a query that has multiple steps (e.g., steps 1, 2, 3, 4, etc). I want at step 4 of the query to reference step 2 of the query (I'm doing this because I need to do a grouping).

 

How can I have the query reference itself? The way I've dealt with this in the past is that I just copy and paste the query and keep steps 1 and 2....the query is now running very slow (I think because it has to basically do the query twice) and I want to see if there is a way to speed it up.

 

 

 

 

2 ACCEPTED SOLUTIONS
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

If you reference the previous step or even query there is a chance it will run the code twice anyway as steps are not loaded or stored anywhere during the execution process or else you use Table.Buffer or List.Buffer function. If you want to avoid expecting the same query twice, you can watch this video it might help you.

https://www.youtube.com/watch?v=3uKNNZqBIkg&t=764s

 

If this is not the answers to your requirement you can try explaining your scenario in more detailed.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

mahoneypat
Employee
Employee

To reference an earlier step, just right click on your last step and choose "Insert Step After".  Then, in the formula bar type in 

 

= #"Changed Type"  (or whatever the earlier step is named)

 

Good practice is to rename your steps so they are more meaningful especially when you start jumping around the query.  Also good to rename with no spaces so you don't have to worry about all the #"  "s.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Employee
Employee

To reference an earlier step, just right click on your last step and choose "Insert Step After".  Then, in the formula bar type in 

 

= #"Changed Type"  (or whatever the earlier step is named)

 

Good practice is to rename your steps so they are more meaningful especially when you start jumping around the query.  Also good to rename with no spaces so you don't have to worry about all the #"  "s.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

If you reference the previous step or even query there is a chance it will run the code twice anyway as steps are not loaded or stored anywhere during the execution process or else you use Table.Buffer or List.Buffer function. If you want to avoid expecting the same query twice, you can watch this video it might help you.

https://www.youtube.com/watch?v=3uKNNZqBIkg&t=764s

 

If this is not the answers to your requirement you can try explaining your scenario in more detailed.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors