Friday, May 8, 2026
banner
Top Selling Multipurpose WP Theme

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

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

When you acknowledged your self in (at the very least) one of many two conditions specified above, then please proceed studying this text.

Effective, you might be curious to search 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 characteristic 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 reworked alongside the way in which, to fit your reporting wants higher — for instance, do you need to carry out foreign money conversion, or do it’s good to conform nation and metropolis names?

Do you acknowledge 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 if you happen to import the info into your information mannequin like this, you’re going to get incorrect outcomes — as every New York, NYC, and New York Metropolis shall be handled as a separate entity. This, and plenty of extra potential caveats, should be solved throughout the Knowledge Shaping section, and that’s why it’s necessary to spend a while massaging your information.

Energy Question

When you don’t carry out information transformations on the supply aspect, the subsequent 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 keeping with Microsoft’s official documentation, you’ll be able to apply greater than 300 completely different transformations!

The important thing benefit of Energy Question is you could carry out complicated information transformations with little or no coding abilities! Moreover, all steps you’ve utilized throughout the information transformation course of are being saved, so each time you refresh your dataset, these steps shall be mechanically utilized to form your information and put together it for consumption through stories.

Underneath the hood of Energy Question is a Mashup engine, that allows your information shaping to run easily. Energy Question makes use of a really highly effective M language for information manipulation. And, now you might be most likely asking yourselves, what does all this story about information shaping, Energy Question, Mashup engine, M language, and many others. need to do with Question folding? I don’t blame you, it’s a good query, however we’ll come again quickly to reply it.

What’s a Question folding?

For some information sources, comparable to relational databases, but in addition 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” — normally, it’s SQL.

Photo by Josh Sorenson on Pexels

By pushing complicated calculations and transformations on to a supply, Energy Question leverages the capabilities of the strong relational database engines, which are constructed to deal with giant volumes of information in essentially the most environment friendly approach.

That potential 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 aspect, we are saying that the question folds.

Knowledge sources that help Question folding

As already talked about, the obvious beneficiary of question folding is relational database sources, comparable 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.

Then again, if you use information sources comparable to Excel information, BLOB storage information, flat information, and many others. in your Energy BI datasets, the question can’t fold.

Knowledge Transformations that help Question folding

Nevertheless, with regards to information sources that help question folding normally, it’s necessary to needless to say not all transformations could be folded and pushed to an information 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 refined variations within the Energy Question transformations could be decisive within the ultimate consequence, and whether or not your question will fold or not. I’ll present you a number of of these refined variations within the following sections.

Typically talking, the next transformations, when utilized in Energy Question, could 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 could be translated to JOIN in SQL. After I stated, merging of foldable queries — meaning it is going to work if you’re becoming a member of two SQL server tables, nevertheless it won’t 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 capabilities which have equivalents in SQL language, for instance, mathematical capabilities, or textual content manipulation capabilities
  • Pivot and Unpivot transformations

Then again, some transformations that can forestall the question from folding are:

  • Merging queries primarily based on completely different sources, as defined beforehand
  • Appending (union-ing) queries primarily based on completely different sources — related logic as within the earlier case
  • Including customized columns with complicated logic or utilizing some M capabilities 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 needless to say altering a column information sort could be each a foldable and a non-foldable transformation

Now, let’s study why it is very important obtain this habits — or, perhaps it’s higher to say, why do you have to care if the question folds or not?

Why do you have to care about Question folding?

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

In case you are working with DirectQuery or Twin storage mode, as you might be concentrating on the SQL database immediately, all of your transformations MUST fold — or your answer won’t work.

Lastly, question folding can also be of key significance for Incremental refresh — it’s so necessary that Energy BI will warn you as soon as it determines that question folding can’t be achieved. It won’t break your incremental refresh “per-se”, however with out question folding in place, an incremental refresh wouldn’t serve its essential objective — to scale 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, it is best to have a tendency to attain question folding at any time when attainable.

Gradual report — don’t blame Question folding!

One necessary disclaimer right here, and this is likely one of the key takeaways from this sequence 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, it is best to examine your Energy Question steps in additional depth.

All or nothing?

A couple of extra issues to bear in mind relating to question folding. It’s not an all-or-nothing course of. Which means you probably 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 could’t be achieved anymore.

Picture by creator

To simplify, you probably 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 could’t be achieved once more, even you probably have transformations that help question folding by default in steps 6 to 10 — like in our instance the place filtering needs to be a foldable step, these steps won’t fold. Preserve that in thoughts, and attempt to push all non-foldable steps down the pipeline as a lot as attainable.

How are you aware if the question folds?

Okay, now we aren’t rookies anymore. We all know what question folding is, why we should always attempt to attain it, and a few refined methods that may make an enormous distinction.

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

If it’s greyed out, this step most likely doesn’t fold. Then again, if you’ll be able to click on on this feature, that signifies that your question will fold. I suppose you might be perhaps confused with the phrase: PROBABLY!

Picture by creator

However, that’s the correct phrase, as you’ll be able to’t be 100% positive that if the View Native Question choice is disabled, your question doesn’t fold. I’ll present you later how this feature can trick us into pondering that the question folding was damaged, despite the fact that, in actuality, folding truly happens.

As an alternative, if you need to ensure in case your question folds or not, you need to use the Question Diagnostics characteristic inside Energy Question Editor, or SQL Server Profiler, like previous and dependable solution to test the queries despatched to a database by the Energy BI engine.

Moreover, there’s a cool characteristic in Energy Question On-line, the place every step is marked with the icon that reveals if that step folds, doesn’t fold, or is unknown. As I stated, this characteristic 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 creator

The satan is within the particulars…

Effective…You’ve most likely heard concerning the saying that the satan is within the particulars. Now, it’s time to know how little nuances could make an enormous distinction in our information transformation course of.

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

Satan #1 — Merge Be part of

This one could be very fascinating, as you’ll hardly assume what is occurring 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 among the columns from my reality 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 a part of the DimCustomer desk as it’s, with none further steps earlier than merging.

Picture by creator

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 a part of (left, outer, or internal).

Picture by creator

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

Picture by creator

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 signifies that question didn’t fold!

Picture by creator

How will we resolve this? Let’s simply select a clean question and write our M code by hand to attain precisely the identical end result.

Picture by creator

The important thing factor is that we are going to use an analogous, however nonetheless completely different M operate: Desk.Be part of.

We are actually utilizing Desk.Be part of operate – Picture by creator

All operate arguments are precisely the identical as beforehand, and let’s now test the end result.

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

Picture by creator

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

Picture by creator

Oh, boy, we had been tricked — this step certainly folded! As you’ll be able to 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 a part of sort, which we had been in a position to resolve by tweaking the mechanically generated M code. And, the opposite one was the inaccurate habits of the View Native Question choice. I’ll present you within the subsequent a part of the sequence yet another instance when View Native Question lies.

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

I assume you are actually accustomed to 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 ultimate a part of the article, I’ll present you a number of extra fascinating findings.

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

Altering Knowledge sorts

Probably the most widespread transformations in Energy Question is altering information sort. It’s a widely known best practice to use proper data types in your information mannequin — for instance, if you happen to don’t want hours, minutes, and seconds stage of granularity in your stories, you need to be higher off eliminating them and altering the info sort of that column from Date/Time to Date solely.

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

Picture by creator

As you’ll be able to spot within the illustration above, my OrderDate column is of Date/Time information sort. And, I need to change it to Date solely. There are (at the very least) two attainable choices to do that — the primary one is to right-click on the column, broaden the drop-down for the Change Kind choice (like I did within the illustration), and choose Date sort (just under the Date/Time):

Picture by creator

A couple of necessary issues occurred right here, so let me clarify every of these:

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

Let’s now study the opposite choice to alter information sort of our column:

Picture by creator

Just under our earlier Change Kind choice, there’s a Remodel choice. When you broaden the drop-down, you’ll be able to see the Date Solely transformation. Let’s click on on it and test what occurs:

Picture by creator

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

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

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

Takeover from this story: watch out, and be careful if 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 another instance when the View Native Question choice 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 reality desk:

Picture by creator

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 creator

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 operate in T-SQL:

Picture by creator

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

Picture by creator

Let’s test this in our Question Diagnostics software:

Picture by creator

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

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

The last word efficiency check

Okay, if I didn’t handle to persuade you up to now, why it is best to attempt to attain 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!

Take a look at #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 display the magnitude of significance of the question folding idea.

Within the first instance, I’ve utilized 9 completely different transformation steps, and all of them are foldable, as you’ll be able to see within the following illustration:

Picture by creator

Don’t take note of the SQL code that the Mashup engine generated: if you’re a SQL skilled, after all, you can write rather more optimum SQL code — nonetheless, needless to say with auto-generated scripts by the Mashup engine, you aren’t getting the most optimum SQL — you might be 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 creator

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 effective indicator that the question folding is in place.

Take a look at #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 isn’t foldable:

Picture by creator

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 won’t fold!

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

Picture by creator

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 instances extra than in our earlier case when the question folded. This time, batches of loaded information had been between 10.000 and 20.000 information.

However, what’s much more regarding — you’ll be able to see that the whole variety of information loaded was virtually 11 million!!! As an alternative of two.8 million within the earlier instance! Why is it taking place? Nicely, within the earlier sections, I defined that when the Mashup engine can’t translate M language to SQL, it wants to drag 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 crucial transformations had been carried out on the SQL database aspect, and the Mashup engine received an already ready information set. Whereas within the second situation, after we broke the question folding, the Mashup engine pulled the entire remaining rows (approx. 11 million), and solely after that was it in a position to apply different transformation steps.

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

Conclusion

Nicely, we lined rather a lot on this article. We realized concerning the information shaping idea, we launched Energy Question fundamentals, and we additionally realized what question folding is and why we should always do our greatest to attain it.

I’ve additionally shared with you some primary examples and neat methods on how one can obtain question folding in some widespread use instances.

In the long run, please bear in mind that the question folding is a piece in progress, and folk from the Energy BI crew are continuously bettering this characteristic. So, it could occur that among the points with question folding I’ve proven you listed below are resolved within the meantime. Subsequently, make sure you keep updated with the newest enhancements.

Thanks for studying!

banner
Top Selling Multipurpose WP Theme

Converter

Top Selling Multipurpose WP Theme

Newsletter

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

banner
Top Selling Multipurpose WP Theme

Leave a Comment

banner
Top Selling Multipurpose WP Theme

Latest

Best selling

22000,00 $
16000,00 $
6500,00 $
15000,00 $

Top rated

6500,00 $
22000,00 $
900000,00 $

Products

Knowledge Unleashed
Knowledge Unleashed

Welcome to Ivugangingo!

At Ivugangingo, we're passionate about delivering insightful content that empowers and informs our readers across a spectrum of crucial topics. Whether you're delving into the world of insurance, navigating the complexities of cryptocurrency, or seeking wellness tips in health and fitness, we've got you covered.