Close Menu
    Facebook LinkedIn YouTube WhatsApp X (Twitter) Pinterest
    Trending
    • Munich-based encosa raises €25 million to bring battery storage to German SMEs
    • Websites Can Now Spy on You Through Your Hard Drive
    • Kalshi debuts regulated crypto perpetual futures
    • Apple Will Reportedly Add Bill-Splitting Feature to iOS 27
    • Escaping the Valley of Choice in BI
    • SEO headline New urine test uses gut biomarkers to identify autism earlier
    • Socceroos legend Tim Cahill backs sports swag design platform Nardo in $1 million pre-Seed raise
    • ‘Sexual Chocolate’ Faces Recalls After FDA Tests Reveal Undisclosed Viagra
    Facebook LinkedIn WhatsApp
    Times FeaturedTimes Featured
    Tuesday, June 2
    • Home
    • Founders
    • Startups
    • Technology
    • Profiles
    • Entrepreneurs
    • Leaders
    • Students
    • VC Funds
    • More
      • AI
      • Robotics
      • Industries
      • Global
    Times FeaturedTimes Featured
    Home»Artificial Intelligence»What Is a Query Folding in Power BI and Why should You Care?
    Artificial Intelligence

    What Is a Query Folding in Power BI and Why should You Care?

    Editor Times FeaturedBy Editor Times FeaturedJuly 26, 2025No Comments21 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr WhatsApp Email
    Share
    Facebook Twitter LinkedIn Pinterest Telegram Email WhatsApp Copy Link


    a question folding?” “Does your question fold?”… Perhaps somebody requested you these questions, however you have been like: “Question…Whaaaat?!”

    Or, possibly you’ve heard about question folding in Energy BI, however didn’t know learn how to reap the benefits of it in real-life situations.

    In the event you acknowledged your self in (no less than) one of many two conditions specified above, then please proceed studying this text.

    High-quality, you’re curious to seek out out what a Question folding is. However, first issues first…Earlier than you proceed, we have to set up some theoretical foundations, which is able to put the Question folding function within the correct context.

    Knowledge Shaping

     and why it is one of the key concepts in the data preparation phase. Now, I would like to expand on that in a (maybe) unusual way:

    I guess you all know about the book written by Thomas More, called “Utopia”.

    In that story, everything is perfect and everyone is satisfied. In an ideal world, let’s call it “Data Utopia”, we have clean, high-quality data that just flies into our reports “as-is”, without needing to perform any kind of face-lifting or transformations along the way. Unfortunately, “Data Utopia” can exist only in books — the reality is crueler — as we have to deal with numerous challenges while nurturing our data.

    That being said, one of the key concepts that we have to absorb is Data Shaping. Data shaping is the process you should perform once you get familiar with your data, and become aware of possible pitfalls within the data you are planning to use in your business intelligence solution.

    I’ve intentionally used the term “Business Intelligence” instead of “Power BI”, as this is a general concept that should be used outside of Power BI solutions too.

    In simple words, data shaping is the process of data consolidation, BEFORE it becomes part of your data model. The key thing to keep in mind is the word: BEFORE! So, one would perform data shaping before the data goes into the report itself. Data shaping can be done at different places, and, depending on where you apply data shaping techniques, at different points in time during the data preparation process.

    WHERE should you perform data shaping?

    Source Database — This is the most obvious choice and in most cases the most desirable scenario. It is based on traditional data warehousing principles of Extracting-Transforming-Loading (ETL) data. In this scenario, you define what data you want to extract (not all data from the database is needed, and it’s usually not a good idea to import all the data). Then, you resolve in case your information must be remodeled alongside the way in which, to fit your reporting wants higher — for instance, do you need to carry out forex conversion, or do you have to conform nation and metropolis names?

    Do you acknowledge the town within the following picture?

    Image by Lukas Kloeppel on Pexels

    Sure, it’s New York. Or, is it NYC? Or, is it New York Metropolis? Which considered one of these three names is appropriate? Sure, all of them are appropriate — however in case you import the info into your information mannequin like this, you’ll get incorrect outcomes — as every New York, NYC, and New York Metropolis can be handled as a separate entity. This, and plenty of extra potential caveats, should be solved in the course of the Knowledge Shaping section, and that’s why it’s vital to spend a while massaging your information.

    Energy Question

    In the event you don’t carry out information transformations on the supply facet, the following station is Energy Question — it’s the built-in software inside Energy BI, that enables you to perform all kinds of transformations to your data. In line with Microsoft’s official documentation, you possibly can apply greater than 300 totally different transformations!

    The important thing benefit of Energy Question is that you may carry out advanced information transformations with little or no coding expertise! Moreover, all steps you’ve utilized in the course of the information transformation course of are being saved, so each time you refresh your dataset, these steps can be robotically utilized to form your information and put together it for consumption through studies.

    Beneath the hood of Energy Question is a Mashup engine, that permits your information shaping to run easily. Energy Question makes use of a really highly effective M language for information manipulation. And, now you’re most likely asking yourselves, what does all this story about information shaping, Energy Question, Mashup engine, M language, and so on. must do with Question folding? I don’t blame you, it’s a good query, however we are going to come again quickly to reply it.

    What’s a Question folding?

    For some information sources, equivalent to relational databases, but additionally non-relational information sources, for instance, OData, AD, or Alternate, the Mashup engine is ready to “translate” M language to a language that the underlying information supply will “perceive” — typically, it’s SQL.

    Photo by Josh Sorenson on Pexels

    By pushing advanced calculations and transformations on to a supply, Energy Question leverages the capabilities of the sturdy relational database engines, which can be constructed to deal with giant volumes of information in probably the most environment friendly means.

    That means of Energy Question’s Mashup engine to create a single SQL assertion combining all M statements behind your transformations is what we name Question folding.

    Or, let`s make it easy: if the Mashup engine is ready to generate a single SQL question that’s going to be executed on the info supply facet, we are saying that the question folds.

    Knowledge sources that assist Question folding

    As already talked about, the obvious beneficiary of question folding is relational database sources, equivalent to SQL Server, Oracle, or MySQL. Nevertheless, it`s not simply that SQL databases reap the benefits of the question folding idea. Basically, any information supply that helps some sort of querying language can probably reap the benefits of question folding. These different information sources are OData, SSAS, SharePoint lists, Alternate, and Entra ID.

    Alternatively, once you use information sources equivalent to Excel information, BLOB storage information, flat information, and so on. in your Energy BI datasets, the question can’t fold.

    Knowledge Transformations that assist Question folding

    Nevertheless, on the subject of information sources that assist question folding basically, it’s vital to take into account that not all transformations might be folded and pushed to a knowledge supply. So, simply to be clear, the truth that a SQL database helps question folding doesn’t essentially imply that your question will fold! There are some Energy Question transformations that merely can`t be pushed to a SQL database engine.

    Fairly often, some delicate variations within the Energy Question transformations might be decisive within the last consequence, and whether or not your question will fold or not. I’ll present you a couple of of these delicate variations within the following sections.

    Usually talking, the next transformations, when utilized in Energy Question, might be “translated” to a single SQL assertion:

    • Eradicating columns
    • Renaming columns
    • Filtering rows, with static values or Energy Question parameters, as they’re handled as WHERE clause predicates in SQL
    • Grouping and summarizing, that are equal to SQL’s Group by clause
    • Merging of foldable queries primarily based on the identical supply, as this operation might be translated to JOIN in SQL. Once I stated, merging of foldable queries — which means it’s going to work if you’re becoming a member of two SQL server tables, however it is not going to work if you’re attempting to hitch a SQL desk and an Excel file
    • Appending foldable queries primarily based on the identical supply — this transformation pertains to the UNION ALL operator in SQL
    • Including customized columns with easy logic. What does easy logic imply? Utilizing M features which have equivalents in SQL language, for instance, mathematical features, or textual content manipulation features
    • Pivot and Unpivot transformations

    Alternatively, some transformations that may forestall the question from folding are:

    • Merging queries primarily based on totally different sources, as defined beforehand
    • Appending (union-ing) queries primarily based on totally different sources — related logic as within the earlier case
    • Including customized columns with advanced logic or utilizing some M features that don’t have a counterpart in SQL
    • Including index columns
    • Altering a column information sort. This one is a typical “it relies upon” case. I’ll present you quickly what it relies on, however simply take into account that altering a column information sort might be each a foldable and a non-foldable transformation

    Now, let’s look at why it is very important obtain this conduct — or, possibly it’s higher to say, why must you care if the question folds or not?

    Why must you care about Question folding?

    While you’re utilizing Import mode in Energy BI, the info refresh course of will work extra effectively when the question folds, each when it comes to refresh velocity and useful resource consumption.

    If you’re working with DirectQuery or Twin storage mode, as you’re concentrating on the SQL database instantly, all of your transformations MUST fold — or your answer is not going to work.

    Lastly, question folding can be of key significance for Incremental refresh — it’s so vital that Energy BI will warn you as soon as it determines that question folding can’t be achieved. It is not going to break your incremental refresh “per-se”, however with out question folding in place, an incremental refresh wouldn’t serve its major goal — to cut back the quantity of information that must be refreshed in your information mannequin — as with out question folding, Mashup engine must retrieve all information from the supply after which apply subsequent steps to filter the info.

    With all these in thoughts, you must have a tendency to realize question folding each time doable.

    Gradual report — don’t blame Question folding!

    One vital disclaimer right here, and this is likely one of the key takeaways from this collection of weblog posts: in case your report is sluggish, or your visuals need a lot of time to render, or your data model size is large, question folding has nothing to do with it!

    Provided that your information refresh or incremental refresh is sluggish and inefficient, you must examine your Energy Question steps in additional depth.

    All or nothing?

    A number of extra issues to remember relating to question folding. It’s not an all-or-nothing course of. Which means if in case you have, let’s say, 10 transformation steps inside Energy Question, and your question folds till the sixth step, you’ll nonetheless get some profit from partial question folding. Nevertheless, as soon as the question folding is damaged, it might probably’t be achieved anymore.

    Picture by writer

    To simplify, if in case you have 10 transformation steps, and your question folding is damaged within the fifth step, all earlier steps will fold, however as soon as the folding is damaged, it might probably’t be achieved once more, even if in case you have transformations that assist question folding by default in steps 6 to 10 — like in our instance the place filtering ought to be a foldable step, these steps is not going to fold. Preserve that in thoughts, and attempt to push all non-foldable steps down the pipeline as a lot as doable.

    How are you aware if the question folds?

    Okay, now we’re not rookies anymore. We all know what question folding is, why we should always try to realize it, and a few delicate tips that may make an enormous distinction.

    Now, it’s time to learn to verify if the precise question folds or not. The primary and most evident means is to right-click on the step and verify what the View Native Question possibility seems to be like.

    If it’s greyed out, this step most likely doesn’t fold. Alternatively, if you’ll be able to click on on this selection, that implies that your question will fold. I assume you’re possibly confused with the phrase: PROBABLY!

    Picture by writer

    However, that’s the right phrase, as you possibly can’t be 100% certain that if the View Native Question possibility is disabled, your question doesn’t fold. I’ll present you later how this selection can trick us into pondering that the question folding was damaged, although, in actuality, folding truly happens.

    As an alternative, once you need to make sure in case your question folds or not, you should utilize the Question Diagnostics function inside Energy Question Editor, or SQL Server Profiler, like a superb outdated and dependable option to verify the queries despatched to a database by the Energy BI engine.

    Moreover, there’s a cool function in Energy Question On-line, the place every step is marked with the icon that exhibits if that step folds, doesn’t fold, or is unknown. As I stated, this function is on the market solely in Energy Question On-line at this second, so let’s hope that the Energy BI crew will implement it within the Desktop model quickly.

    Picture by writer

    The satan is within the particulars…

    High-quality…You’ve most likely heard in regards to the saying that the satan is within the particulars. Now, it’s time to know how little nuances could make a giant distinction in our information transformation course of.

    Let’s begin with probably the most curious circumstances in Energy Question editor…

    Satan #1 — Merge Be a part of

    This one may be very fascinating, as you’ll hardly assume what is going on within the background. Let’s say that I need to mix two of my queries into one. I’ll use the Journey Works pattern database, and I have to merge the FactInternet Gross sales and DimCustomer tables.

    I’ll take away a few of the columns from my truth desk, and maintain solely the CustomerKey column, as it is a overseas key to a DimCustomer desk, and the Gross sales Quantity column. I’ll be part of the DimCustomer desk as it’s, with none extra steps earlier than merging.

    Picture by writer

    Merging tables is equal to JOIN operation in SQL. Basically, we select the column on which we need to carry out MERGE operation, and the kind of be part of (left, outer, or inside).

    Picture by writer

    The issue is that by default, once you’re merging two queries, Energy Question will generate a nested be part of assertion, which might’t be correctly translated in SQL.

    Picture by writer

    If I’m going to the Instruments tab and click on on Diagnose Step, I can see that the Mashup engine fired two separate queries to my underlying SQL Server database — in different phrases, these two queries couldn’t be executed as a single SQL assertion, and that implies that question didn’t fold!

    Picture by writer

    How can we clear up this? Let’s simply select a clean question and write our M code by hand to realize precisely the identical consequence.

    Picture by writer

    The important thing factor is that we are going to use the same, however nonetheless totally different M perform: Desk.Be a part of.

    We are actually utilizing Desk.Be a part of perform – Picture by writer

    All perform arguments are precisely the identical as beforehand, and let’s now verify the result.

    You bear in mind as soon as I informed you that when the View Native Question is greyed out, your question most likely doesn’t fold, however it’s not 100% appropriate. And, it is a good instance. In the event you check out View Native Question, it nonetheless exhibits that our question doesn’t fold…

    Picture by writer

    …however let’s go to Diagnostics and verify if that’s true.

    Picture by writer

    Oh, boy, we have been tricked — this step certainly folded! As you possibly can see within the illustration above, we’ve a single SQL question generated and despatched to a SQL Server supply database to be executed.

    So, we discovered two devils on this instance — the primary one was a be part of sort, which we have been capable of clear up by tweaking the robotically generated M code. And, the opposite one was the inaccurate conduct of the View Native Question possibility. I’ll present you within the subsequent a part of the collection yet one more instance when View Native Question lies.

    Question folding in Energy BI — tips, lies & final efficiency check

    I assume you are actually aware of the idea of question folding in Energy BI, and particularly with its significance for information refresh and incremental refresh processes. We’ve additionally began to scratch some fascinating behaviors of Energy Question transformations, and on this last a part of the article, I’ll present you a couple of extra fascinating findings.

    Lastly, we are going to wrap it up with the final word efficiency check — I’ll present you the precise numbers behind two an identical queries — one folds, and the opposite doesn’t!

    Altering Knowledge sorts

    One of the vital frequent transformations in Energy Question is altering information sort. It’s a well known best practice to use proper data types in your information mannequin — for instance, in case you don’t want hours, minutes, and seconds stage of granularity in your studies, you ought to be higher off eliminating them and altering the info sort of that column from Date/Time to Date solely.

    Nevertheless, the highway to hell is paved with good intentions:)…So, let me present you one delicate distinction that may trigger your question to turn into rattling sluggish, although you’ve caught with the advice to make use of a correct information sort!

    Picture by writer

    As you possibly can spot within the illustration above, my OrderDate column is of Date/Time information sort. And, I need to swap it to Date solely. There are (no less than) two doable choices to do that — the primary one is to right-click on the column, broaden the drop-down for the Change Sort possibility (like I did within the illustration), and choose Date sort (slightly below the Date/Time):

    Picture by writer

    A number of vital issues occurred right here, so let me clarify every of these:

    1. Within the Utilized Steps pane, you possibly can discover that our transformation step had been recorded
    2. Within the column itself, you possibly can see that the time portion disappeared
    3. Once I’ve opened the View Native Question dialog field, you possibly can see that the Mashup engine properly translated our transformation to a T-SQL CONVERT() perform
    4. The M system utilized to this transformation step is: Desk.TransformColumnTypes()

    Let’s now look at the opposite possibility to vary information sort of our column:

    Picture by writer

    Just under our earlier Change Sort possibility, there’s a Rework possibility. When you broaden the drop-down, you possibly can see the Date Solely transformation. Let’s click on on it and verify what occurs:

    Picture by writer

    Seems to be fairly related, does it? However, let’s stroll by means of all of the issues that occurred now:

    1. As an alternative of the Modified Sort step, we now have a step referred to as Extracted Date
    2. The column itself seems to be precisely the identical as within the earlier instance — no time half in there
    3. Ooops, the question doesn’t fold anymore! As you possibly can see, the View Native Question possibility is greyed out!
    4. This time, M system utilized is: Desk.TransformColumns()

    So, one single totally different phrase within the M system (Desk.TransformColumnTypes vs Desk.TransformColumns) affected our question so arduous that it couldn’t be translated to SQL!

    Takeover from this story: watch out, and be careful once you’re selecting choices for altering information sorts!

    Liar, Liar…

    I’ve promised within the earlier a part of the article that I’ll present you yet one more instance when the View Native Question possibility can idiot you into pondering that question folding was damaged, even when in actuality it’s not true…

    Let’s say that we need to maintain solely the highest X rows from our desk. In my case, I need to protect the highest 2000 rows from my truth desk:

    Picture by writer

    As soon as I’ve utilized this step and checked the View Native Question, I can understand that my question folds, as my transformation was translated to a TOP clause in SQL:

    Picture by writer

    Now, let’s say that I need to apply Absolute worth transformation on my Gross sales Quantity column. Usually, this transformation simply folds, as there’s an ABS perform in T-SQL:

    Picture by writer

    Nevertheless, if I right-click on this step, I’ll see that the View Native Question possibility is greyed out, so I might assume that this step broke my question folding!

    Picture by writer

    Let’s verify this in our Question Diagnostics software:

    Picture by writer

    Oh, my God! This step folded certainly! So, we have been tricked by the View Native Question possibility once more!

    The important thing takeover right here is: everytime you’re assuming {that a} particular transformation step might be folded (like on this instance, once we knew that SQL has an ABS perform to assist our transformation), double-check what actually occurs below the hood!

    The final word efficiency check

    Okay, if I didn’t handle to persuade you to this point, why you must try to realize question folding, let me now pull my final ace up my sleeve!

    I need to present you the distinction in information refresh efficiency between the queries that return precisely the identical outcomes — considered one of them folds, and the opposite doesn’t!

    Check #1 Question folding ON

    For this testing, I’ll use the FactOnlineSales desk from the Contoso pattern database. This desk has round 12.6 million rows, and it’s good to exhibit the magnitude of significance of the question folding idea.

    Within the first instance, I’ve utilized 9 totally different transformation steps, and all of them are foldable, as you possibly can see within the following illustration:

    Picture by writer

    Don’t take note of the SQL code that the Mashup engine generated: if you’re a SQL skilled, in fact, you could possibly write way more optimum SQL code — nevertheless, take into account that with auto-generated scripts by the Mashup engine, you aren’t getting the most optimum SQL — you’re simply getting appropriate SQL!

    I’ll hit Shut & Apply and activate my stopwatch to measure how a lot time my information refresh lasts.

    Picture by writer

    This question took 32 seconds to load 2.8 million information in my Energy BI report. Knowledge was loaded in batches of 100.000–150.000 information, which is an efficient indicator that the question folding is in place.

    Check #2 Question folding OFF

    Now, I’ll return to Energy Question Editor, and deliberately break question folding on the third step (bear in mind the instance above with altering Date/Time sort to Date), utilizing the transformation for which I do know that’s not foldable:

    Picture by writer

    Fact to be stated, I’ll obtain a partial folding right here, as first two steps will fold, however all subsequent steps after the Extracted Date transformation is not going to fold!

    Let’s activate the stopwatch once more and verify what occurs:

    Picture by writer

    The very first thing to note: this question took 4 minutes and 41 seconds to load into our Energy BI report, which is roughly 10 occasions extra than in our earlier case when the question folded. This time, batches of loaded information have been between 10.000 and 20.000 information.

    However, what’s much more regarding — you possibly can see that the entire variety of information loaded was virtually 11 million!!! As an alternative of two.8 million within the earlier instance! Why is it occurring? Nicely, within the earlier sections, I defined that when the Mashup engine can’t translate M language to SQL, it wants to tug ALL the info (from the second when the question folding was damaged), and THEN apply transformations on the entire chunk of imported information!

    The ultimate result’s precisely the identical — we’ve 2.830.017 information in our Energy BI report — however, with question folding in place, all essential transformations have been carried out on the SQL database facet, and the Mashup engine acquired an already ready information set. Whereas within the second state of affairs, after we broke the question folding, the Mashup engine pulled the entire remaining rows (approx. 11 million), and solely after that was it capable of apply different transformation steps.

    And, this was only a fundamental instance, with one single desk, and never so huge when it comes to information quantity! Merely think about the magnitude of implications on a bigger dataset, with a number of tables in it.

    Conclusion

    Nicely, we coated so much on this article. We discovered in regards to the information shaping idea, we launched Energy Question fundamentals, and we additionally discovered what question folding is and why we should always do our greatest to realize it.

    I’ve additionally shared with you some fundamental examples and neat tips on learn how to obtain question folding in some frequent use circumstances.

    Ultimately, please remember that the question folding is a piece in progress, and people from the Energy BI crew are continuously enhancing this function. So, it might probably occur that a few of the points with question folding I’ve proven you listed below are resolved within the meantime. Subsequently, you’ll want to keep updated with the most recent enhancements.

    Thanks for studying!



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Editor Times Featured
    • Website

    Related Posts

    Escaping the Valley of Choice in BI

    June 2, 2026

    Ensuring Data Integrity with Cryptographic Hashing and the Ethereum Blockchain

    June 1, 2026

    RAG Is Not Machine Learning, and the ML Toolkit Solves the Wrong Problem

    June 1, 2026

    How to Combine Claude Code and Codex for Maximum Coding Power

    June 1, 2026

    It’s the Lessons We Learned Along the Way. Or, Is It?

    June 1, 2026

    Proxy-Pointer RAG: Eliminating Wasteful Entity & Relations Extraction in Knowledge Graphs

    May 31, 2026

    Comments are closed.

    Editors Picks

    Munich-based encosa raises €25 million to bring battery storage to German SMEs

    June 2, 2026

    Websites Can Now Spy on You Through Your Hard Drive

    June 2, 2026

    Kalshi debuts regulated crypto perpetual futures

    June 2, 2026

    Apple Will Reportedly Add Bill-Splitting Feature to iOS 27

    June 2, 2026
    Categories
    • Founders
    • Startups
    • Technology
    • Profiles
    • Entrepreneurs
    • Leaders
    • Students
    • VC Funds
    About Us
    About Us

    Welcome to Times Featured, an AI-driven entrepreneurship growth engine that is transforming the future of work, bridging the digital divide and encouraging younger community inclusion in the 4th Industrial Revolution, and nurturing new market leaders.

    Empowering the growth of profiles, leaders, entrepreneurs businesses, and startups on international landscape.

    Asia-Middle East-Europe-North America-Australia-Africa

    Facebook LinkedIn WhatsApp
    Featured Picks

    Greg Brockman Defends $30B OpenAI Stake: ‘Blood, Sweat, and Tears’

    May 5, 2026

    H&R Block Coupons and Deals: $50 Off Tax Prep in 2025

    February 19, 2025

    Best MP3 Players for 2026

    May 14, 2026
    Categories
    • Founders
    • Startups
    • Technology
    • Profiles
    • Entrepreneurs
    • Leaders
    • Students
    • VC Funds
    Copyright © 2024 Timesfeatured.com IP Limited. All Rights.
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us

    Type above and press Enter to search. Press Esc to cancel.