One of the most interesting things about Fabric semantic views (announced this week at Ignite) is the way you can combine multiple semantic views together, allowing you to reuse semantic modelling and metrics easily. This has been a long-standing ask for Power BI semantic models and while composite models were created to solve this problem, and had their uses, they never solved the problem properly – mostly because by building composite models on top of a single, physical semantic model that semantic model became a bottleneck. The documentation for semantic views talks about reuse and combining but I thought it would be good to show a simple example to help you understand what’s possible.
First of all, I created a lakehouse called Sales containing three tables: two dimension tables called Employee and Product and a fact table called Sales. I then created a semantic view with the following definition:
version: 0.2.0.dev0
name:"SalesSemanticView"
datasets:
-name: Employee
source: dbo.Employee
-name: Product
source: dbo.Product
-name: Sales
source: dbo.Sales
relationships:
-name: EmployeeToSales
from: Sales
to: Employee
from_columns:
- EmployeeID
to_columns:
- EmployeeID
-name: ProductToSales
from: Sales
to: Product
from_columns:
- ProductID
to_columns:
- ProductID
metrics:
-name: SalesAmount
expression:
dialects:
-dialect: DAX
expression:"SUM('Sales'[SalesAmount])"
This resulted in a Direct Lake semantic model that looked like this:
Next I created another lakehouse called Targets containing just one fact table, a table also called Targets. I created a semantic view with the following definition:
version: 0.2.0.dev0
name:"TargetsSemanticView"
datasets:
-name: Targets
source: dbo.Targets
metrics:
-name: SalesTarget
expression:
dialects:
-dialect: DAX
expression:"SUM('Targets'[SalesTarget])"
This resulted in the following Direct Lake semantic model:
Finally, in a third lakehouse, I created shortcuts to all the tables in the Sales and Targets lakehouses, created a new semantic view and added shortcuts to the two semantic views above inside the folder for this new semantic view:
Here’s the definition of the third semantic view (in the SalesAndTargetsSemanticView folder):
version: 0.2.0.dev0
name:"SalesAndTargetsSemanticView"
relationships:
-name: EmployeeToTargets
from: Targets
to: Employee
from_columns:
- EmployeeID
to_columns:
- EmployeeID
metrics:
-name: SalesPctTarget
expression:
dialects:
-dialect: DAX
expression:"DIVIDE([SalesAmount],[SalesTarget])"
Note that this semantic view doesn’t define any new datasets, just a relationship between the Employee dimension table from the first semantic view and the Targets fact table from the second semantic view, both of which have been shortcutted in to this semantic view, as well as a new metric that references the two measures created in these two other semantic views. This resulted in a Direct Lake semantic model that contained all the tables from the Sales and the Targets lakehouses and their associated semantic views, plus that extra relationship between Employee and Targets and the SalesPctTarget measure:
I could then build a report on this third semantic model and analyse data from both the Sales and Targets lakehouses without duplicating any data, semantic modelling metadata or metrics from either of them:
You have always been able to use shortcuts to tables to use the same table in multiple Direct Lake semantic models. This shows how you can now use shortcuts to semantic views to use the same table metadata, relationships and metrics in multiple semantic models, which I think is pretty cool. It’s still very early days for semantic views of course but I’m excited to see how they develop. If you want to know more about semantic views and Microsoft’s strategy with Apache Ossie, watch this session from Ignite.
A couple of weeks ago I wrote this post about how you can use the new Send Email action in Dataflows Gen2 to send out email-based reports to a list of recipients. I did it by creating a parameterised Dataflow – which worked but the end result was slow and therefore expensive. So I started thinking about other approaches and it turns out there is indeed another way of solving the problem, using a whole branch of M functions that is not properly documented and which I’ve never used before.
They key was understanding that the new Send Email functionality creates something called an action and that Ben Gribaudo wrote a very detailed post on this subject here and which you should probably read before continuing. Specifically, the section on the Action.Sequence function shows how you can compose multiple actions into a sequence. So for example here’s an example of the M code created by the Send Email action:
AlertAction.Send(
MicrosoftOutlook.Actions(),
[
To = {"chris@someemail.com"},
Subject = "Email 1",
Body = "This is an email"
]
)
If you want to send two emails you can create a list of actions and pass it to Action.Sequence as follows:
let
FirstEmail = AlertAction.Send(
MicrosoftOutlook.Actions(),
[
To = {"chris@someemail.com"},
Subject = "Email 1",
Body = "This is the first email"
]
),
SecondEmail = AlertAction.Send(
MicrosoftOutlook.Actions(),
[
To = {"helen@someemail.com"},
Subject = "Email 2",
Body = "This is the second email"
]
),
CreateSequence = Action.Sequence(
{FirstEmail, SecondEmail}
)
in
CreateSequence
With this knowledge it was very easy to adapt the scenario from my previous post to send multiple emails without needing to parameterise.
So, given a query called Sales that returns the following table:
…I created a query that turns that table into a list of records using Table.ToRecords and then uses List.Transform to create a list of actions that send an email, one for each row, and then pass that list of actions to Action.Sequence:
let
TableRows = Table.ToRecords(Sales),
EmailList = List.Transform(
TableRows,
each AlertAction.Send(MicrosoftOutlook.Actions(), [
To = {_[Email]},
Subject = "Sales Report",
Body = "Hi "
& _[Manager]
& ", sales of "
& _[Product]
& " were "
& Number.ToText(_[Sales])
]
)
),
CreateSequence = Action.Sequence(EmailList)
in
CreateSequence
Not only did this work and, when the Dataflow was refreshed, send out four emails identical to the the Dataflow in my previous post:
…but the Dataflow only took 11 seconds to run, which is a huge improvement over the 4 minutes 15 seconds that the parameterised version took:
So we’ve learned a cool new M trick and solved a familiar problem in a new way, which is fun. Is this safe to use in production? Not yet – I don’t fully understand the implications of using actions inside Dataflows so please don’t try this at home. But knowing that you can run your own actions from Dataflows opens up some interesting possibilities to explore in future blog posts.
Something that has got a little attention in the D365 world but not much in the Fabric world is the new functionality for mirring data from D365 Business Central to Fabric, the public preview for which is now live on Appsource here. It was announced at Fabcon in September but I wanted to call it out here in case you had missed it. The docs are can be found here http://aka.ms/bcAnalytics but the best place to start is this video by my colleague Kennie Pontoppidan which has all the latest news:
Definitely something to check out if you want to report on data in D365 Business Central using Fabric!
When the new Send Email action was announced for Fabric Dataflows Gen2 – which allows you to send an email from a dataflow when it refreshes – I was curious to know if you could use it to send multiple emails to multiple different people, and therefore do report bursting or something like it. There are already several different ways to do this in Power BI/Fabric, for example using Power BI report subscriptions or paginated reports, but there might some cases where using a dataflow is easier or more convenient. It turns out that is is possible but only in combination with another relatively new feature: Parameterised Dataflows.
Here’s a simple example. I created a Dataflow Gen2 with a query called Sales that returned the following source data (the email addresses in the Email column have been obscured):
I then created a text parameter in the dataflow called EmailAddress and used it to filter the Sales query so it only returned one row, the row where the value in the Email column matched the value in the EmailAddress parameter. Then I clicked the new Send Email button to create an email destination and edited the resulting M code so it looked like this:
AlertAction.Send(
MicrosoftOutlook.Actions(),
[
To = {EmailAddress},
Subject = "Sales Report",
Body = "Hi "
& Sales{0}[Manager]
& ", sales of "
& Sales{0}[Product]
& " were "
& Number.ToText(Sales{0}[Sales])
]
)
Note that the To line for the destination is the EmailAddress parameter and the Body is a simple M expression that assumes the Sales query returns a table with a single row in it and which generates the contents of the email body.
Here’s what the Dataflow diagram looked like:
I then made sure the “Enable parameters to be discovered and overriden for execution” option was enabled in the Options dialog:
…and saved the dataflow without running it.
Next I created a new Fabric Pipeline with a ForEach activity in it. In the Settings dialog I checked the Sequential box and, being a bit lazy, in Items I used an expression something like this to create an array of all the email addresses from the Sales query in my dataflow:
Then I added a Dataflow activity inside the ForEach activity, pointed it to my dataflow and passed the current value from the ForEach loop (using the expression @item()) into the EmailAddress parameter of my dataflow.
Finally, I ran the Pipeline and checked the inbox of one of the email addresses present in the Sales query and found the following email:
So it worked. Is this a good idea for sending out a large number of emails? Probably not given that it was fairly slow and failed if I tried to introduce any concurrency into the ForEach activity:
But if you only need to send out a few emails and you prefer to use Power Query it’s quite convenient. And when the ability to use HTML formatting in the email body comes (as promised on the Fabric roadmap here, which I guess will be very similar to the new Data Visuals feature) then you will be able to use this technique to send out quite complex reports.
There’s so much going on in the Fabric community that it can be hard to keep up with it all. Semantic Link Labs is a great example: in the six months or so since I last had a proper look at it my colleague Michael Kovalsky has done a whole load of cool things and it wasn’t until I had a chat with him recently that I realised how much had changed. Most importantly, for someone old-fashioned like me who still likes tools with a UI, a lot of new functionality has been added which has a UI and is usable with minimal coding.
To illustrate this, I created a new Fabric notebook in a workspace and installed Semantic Link Labs:
%pipinstallsemantic-link-labs
I then headed over to the Semantic Link Labs Code Examples and copied some of the code from there into cells in my notebook. For example, the following code:
importsempy_labs.semantic_model
sempy_labs.semantic_model.lineage_view()
…opened up a tool for exploring report and semantic model lineage appearing within the notebook. I could connect to a semantic model:
…and then see which reports are connected to it and even look for broken visuals in those reports:
dataset = 'insert id or name of semantic model here'
workspace = 'insert id or name of workspace here'
x = labs.vertipaq_analyzer(dataset=dataset, workspace=workspace)
…and a whole load of other things which probably deserve their own blog post. So if, like me, you had assumed that Semantic Link Labs was for people who like writing code rather than using a UI, take another look – you’ll probably find something useful.
This week, in the announcement about support for Fabric Pipelines in Workspace Monitoring, I noticed that it came with an Operations Agent that actively monitors and analyses Pipeline activity. And that got me thinking, since Workspace Monitoring also contains Power BI activity data, why not create an Operations Agent to actively monitor Power BI too?
I decided to test a really simple scenario. I created a semantic model that contained several measures, one of which returned an error. I then created a report from that semantic model with two pages: one with several working visuals and one with a visual that used the broken measure and which therefore returned an error.
I published this report to a workspace with Workspace Monitoring enabled.
I then created an Operations Agent in the same workspace and connected it to the KQL Database associated with Workspace Monitoring:
Here are my Agent Instructions:
*** Operational Instructions ***
1. Alert me when a DAX query on any of the Power BI semantic models in this workspace returns an error, for example when the DAX in a measure, except when the error is the result of a query being cancelled
2. When you alert me, give me the following information:
a) The username of the user that generated the error
b) The date and time of the error
c) The error message
d) The IDs of the semantic model, the report and the visual that generated the error
e) The OperationID of the query
*** Semantic Instructions ***
1. The SemanticModelLogs table contains information about Power BI activity
2. Every time there is an error, there will be an event with the OperationName "Error"
3. The EventText column for these Error events contains the error message
4. Errors generated by query cancellations, which can be ignored, have an error message in the EventText column that starts with the text "The operation was cancelled by the user"
5. The Timestamp column contains the date and time of the events
6. The ExecutingUser column contains the username of the user that generated the error
7. The ApplicationContext column contains a JSON fragment which gives the IDs of the semantic model (DatasetId), report (ReportId inside the Sources array) and visual (VisualId inside the Sources array)
8. The OperationID column contains the OperationID
Here’s the Playbook that the Operations Agent generated:
And here’s the KQL generated for the DAX Query Error Event Alert:
//DaxQueryErrorEvent: one row per non-cancelled DAX query error event from SemanticModelLogs
DaxQueryErrorIsNonCancelledError=true,//byconstruction: filtered to non-cancelled errors
ExecutingUser=['ExecutingUser'],
ErrorTimestamp=['Timestamp'],
ErrorMessage=['EventText'],
DatasetId=DatasetId,
ReportId=ReportId,
VisualId=VisualId,
OperationId=['OperationId'];
DaxQueryErrorEvent
I have to admit it took several iterations to get the Agent Instructions right so that working KQL was generated, and I would not have been successful without testing the KQL myself and understanding why it wasn’t working. It was not particularly hard to do this though.
I then saved and started the Operations Agent.
Next I opened the report that contained the broken visual, so that I saw an error in the report, and waited. After a few minutes I got the following message in Teams:
So I got a Teams notification when a report containing a broken visual was rendered, which is great and proves the point that Operations Agents can be used to monitor Power BI when used with Workspace Monitoring. You’ll notice that the Teams message doesn’t include the error message, the semantic model, report or visual IDs or any of the other information I requested (although the KQL query generated by the Playbook does return that information) but I guess I need to spend more time tuning the Agent Instructions. Other things I can imagine doing with an Operations Agent include monitoring for failed semantic model refreshes and slow DAX queries. Definitely something I need to spend more time investigating.
This is a blog post I’ve been meaning to write for a long time. Since Fabric launched there has been a lot of focus on Direct Lake mode in Power BI and a lot of people used it because it was the cool new thing. Arguably, we at Microsoft have been guilty of telling people to use it because it was the cool new thing without properly explaining what the benefits are of using it. Direct Lake doesn’t completely replace other storage modes: in a recent post I talked about when Import/DirectQuery composite models are the best choice; Marco wrote a good article on Direct Lake vs Import mode which makes the case for the continuing relevance of Import mode for many scenarios. So what are the main benefits of using Direct Lake mode? Here are the ones I think are important:
Faster and cheaper “refresh”
Refreshing an Import mode semantic model can be slow and can consume a lot of CUs on your capacity. Refreshing a Direct Lake semantic model (also known as framing) is almost instant and consumes minimal CUs. So Direct Lake is better, right? Well no, it’s more complicated than that. Even if refresh is cheap in Direct Lake mode you still need to get the data into OneLake in order to use it, and even if you have data in an existing lakehouse you may need to create a copy to apply additional transformations or to apply VOrder or other table-level optimisations, and it’s the cost and performance of this creation of a gold layer of tables that you should compare with Import mode refresh.
The good news is that it is often faster and cheaper to use another Fabric engine, like Spark, to load the data you need into your gold layer in OneLake than to do an Import mode refresh. For example, in this post on reddit my colleague David Browne gives a simple example of how loading a 20 million row fact table in Spark is half the cost in terms of CUs and marginally faster than refreshing the same table in Import mode; this other post on reddit has similar findings. Other BI projects I’ve seen have shown significant improvements in the time and cost of the operations needed before your end users can view reports with the latest data. Of course there are a lot of factors involved here (How frequently do you need to refresh? Are you using incremental refresh? Are you partitioning your fact table and increasing the amount of parallelism during a refresh? etc) and it is true that, at least at the time of writing, Direct Lake may be marginally slower to query than Import and will have different CU cost characteristics when queried. But the evidence is strong enough for me to say that you should do some testing to see whether Direct Lake will be faster and cheaper for your project.
There are other aspects of cost that need to be taken into account. For example, this “shifting left” of development effort from semantic model refresh to loading data into OneLake means that a specialised set of Power BI semantic model skills around Import mode refresh can be replaced by more commodity skills in areas such as Spark. You may also be able to eliminate a layer in your architecture by using Direct Lake: I’ve seen cases where a relational database is put on top of a data lake just to serve data for Import mode refreshes, something that isn’t necessary with Direct Lake.
My friends who work on internal Microsoft BI teams (who are, incidentally, some of the most sophisticated Fabric developers that I know) tell me that they prefer Direct Lake over Import because it makes them a lot more productive, again reducing costs. One reason is because it means that if they discover a bug in their semantic model that means they have to refresh, they can have their semantic model ready to be queried in seconds once the bug is fixed. They can also do things like run unit tests on feature branches before merging into their repo by spinning up a test semantic model in seconds, querying it then tearing it down again.
Avoidance of memory limits and timeouts during refresh
When you’re working with large Import mode semantic models it’s fairly common to run into errors when you hit memory limits or timeouts during refresh. This can be frustrating. These limits don’t exist when you’re loading data into OneLake for consumption by a Direct Lake model, and while there are plenty of other things that can go wrong when loading data depending on the Fabric workload you’re using, in general Import mode refreshes are harder to manage and require more specialised knowledge.
Reuse of data by multiple semantic models
Think how many Import mode semantic models there are in your tenant. Think how many copies of the same dimension tables, like the Date or Product or Customer dimension tables, there are across them. There may even be cases where the same fact table is duplicated across multiple semantic models. All of these duplicate Import mode tables need to be refreshed individually, which takes time and costs CUs, and refreshing them at different times may result in different semantic models containing different data.
On the other hand, if you plan ahead and use shortcuts judiciously, you can load all of your fact and dimension tables into OneLake once and use them in as many Direct Lake semantic models as you want. This can greatly reduce the CU cost and the time it takes before your data is ready to be queried by a report; it also means that all the semantic models contain exactly the same data. I haven’t seen many cases where people have taken advantage of this yet – probably because it does require you to plan ahead – but where it does happen it leads to huge efficiency gains. And with OneLake security you can apply security once and have it enforced consistently across all Direct Lake semantic models that use the same tables.
In the future it seems likely we’ll be moving away from large, complex semantic models that contain all the data an end user might possibly need to smaller, more focused models that work better for AI. At the same time, while a traditional Power BI report can only connect to one semantic model, the new Rayfin/Fabric apps can connect to multiple semantic models. This means it’s even more likely that the same tables will need to be present in several different semantic models.
Reuse of data by different Fabric engines
Finally, building on that last point, when all of your data is in OneLake with OneLake security applied, it’s not only available to be consumed via Direct Lake semantic models but also by any of the other Fabric engines: it can be queried in SQL via the SQL Endpoint, analysed using code in notebooks and so on. While it is possible to write the contents of an Import mode model to OneLake using the OneLake integration feature, it makes a lot more sense just to load the data into OneLake and use Direct Lake instead if you care about this.
Summary
Maybe the one thing I would disagree with Marco on in the article I referenced above is his statement that Direct Lake is only useful for the 2-3% of semantic models that are hard to manage in Import mode – those that are above 200-400GB in size. While I don’t think you should rip and replace any existing Import mode models that are currently working well, and while very large models will need DirectQuery fact tables, I think the reasons I’ve listed above mean that any new enterprise-scale project that is built completely on Fabric should at least consider using Direct Lake. I’m sure there are people out there who feel differently though, so let’s have a discussion in the comments!
[Thanks to David Browne, Justin Martin, Tamas Polner and Christian Wade for their help writing this post]
For as long as I’ve been using Power BI – which has been from the beginning – the advice about which storage mode to choose has been the same: use Import mode unless you have a really, really good reason to use DirectQuery mode and even then you’re probably wrong and should use Import mode. Import mode was always a lot faster and a lot easier to tune. Marco’s advice in this LinkedIn post from last year pretty much summed up my attitude and that of every other Power BI expert out there:
DirectQuery was only for situations where you either:
Had more data than you could fit in memory, which was very, very rare, or
Where you needed to see truly real-time data in your reports, which business stakeholders always claim they want but they rarely ever need
The addition of Direct Lake as a third storage mode in Fabric didn’t change the situation. While there are some really good reasons to use Direct Lake instead of Import mode (which I should really cover in a separate blog post because I don’t think they are explained properly anywhere), it didn’t change the advice around DirectQuery and I still didn’t think DirectQuery was a good option for most people.
I have now changed my mind. Import or Direct Lake should still be the default for most projects but DirectQuery is now the best choice when you’re working with larger data volumes that could still be handled by Import or Direct Lake. This is a controversial statement, I know, and it’s based on experiences with customers that I can’t talk about directly, and as always there are some important details, so let me explain myself.
My new advice is this. If:
You are starting a new project that is 100% on Fabric and all of your data will be loaded into a Fabric Lakehouse or Warehouse, and
You have the following:
Fact tables with more than a couple of billion rows in them, and
Dimension tables with more than a couple of million rows in them, and/or
Distinct count measures on columns with more than a couple of million distinct values in
Then you should start with a composite model design that uses:
DirectQuery mode fact tables on the Warehouse or SQL Endpoint of your Lakehouse
Dual mode dimension tables (which means they can swap between Import mode and DirectQuery mode when necessary)
Aggregation tables based on your fact tables that are either in Import mode or DirectQuery mode
Why am I recommending this? Well let me take Marco’s objections to DirectQuery mode one by one:
Is Import mode or Direct Lake mode always faster than DirectQuery? For the composite model scenario described above, no, not always. Even if your Import mode or Direct Lake mode model fits within the memory limits of the Fabric capacity that you’re using, then a composite model and DirectQuery fact tables can be almost as fast and may be faster. This is because:
If your query hits an aggregation table, which is potentially a lot smaller than the fact table, then it will be faster than if it hits an Import mode fact table. Of course if your aggregation tables are in Import mode then naturally your query will be faster than if it hits an Import mode fact table, so you could argue that this is an Import mode scenario anyway. But the native aggregation functionality is not available in Import mode or Direct Lake mode at the time of writing, it’s only available if the underlying table is in DirectQuery mode. And yes I know you can simulate aggregations in Import mode with some clever DAX but that clever DAX can also carry an overhead.
The Fabric Warehouse engine, which not only powers Fabric Warehouse but also the SQL Endpoint of a Lakehouse, has improved a lot in the last year and is now incredibly fast. When the new GPU acceleration and other upcoming performance features land then it will be even faster. For example, it’s already faster at doing distinct counts than the Vertipaq engine used by Import or Direct Lake models.
The Warehouse engine also has some architectural advantages over Vertipaq when it comes to concurrency. Now Vertipaq is already really, really good at concurrency and features like semantic model scale-out make it even better, but for the large data volumes mentioned above and when you have more than 5-10 concurrent users then Warehouse is better. It’s actually quite rare to have more than 5-10 genuinely concurrent users (ie users that are running queries at exactly the same time) in a BI solution but it does happen, for example at month-ends.
Is DirectQuery for the rich? Is DirectQuery always more expensive than Import mode or Direct Lake mode? Actually no, not if you’re using a composite model in Fabric for the scenarios we’re talking about.
Let’s say you’re building a large Import mode or Direct Lake mode model in Fabric and you hit the limits of the capacity SKU that you’re using. It could be that you’re hitting the memory limit for your SKU or one of the other Direct Lake guardrails. Or it could be that during your load testing (and you should always do load testing) you hit the CU limits of your capacity. What do you do? Well you can and should do some tuning to see if you can avoid hitting those limits. Or you can scale up to the next capacity size, although that might be expensive. The third option is to use a composite model with DirectQuery fact tables in the way I’ve described.
The first advantage of a composite model with DirectQuery fact tables here is that because only your dimension tables and any Import mode aggregation tables you have are subject to the memory limits for Power BI models that each capacity SKU enforces, you’re much less likely to hit those limits.
The second advantage of a composite model with DirectQuery is that is that if you hit your fact table then Power BI will generate SQL queries against the Warehouse engine and the SQL queries generated are counted as background operations which are then smoothed over 24 hours. DAX queries on Import mode or Direct Lake mode models are counted as interactive operations and are smoothed over 5 to 64 minutes. Queries against a DirectQuery table will still consume some interactive CUs and of course if you hit a Dual mode dimension table or an Import mode aggregation that will also consume interactive CUs, but the Storage Engine is where most of the CUs get burned in an Import or Direct Lake mode model. This is the main reason why a composite model approach can handle more concurrent users: you’re less likely to run into the CU limits for the capacity SKU you’re using because of the difference in how smoothing works.
What’s more, these advantages mean that even if you don’t hit the limits for the capacity SKU you’re using, you could still save money by using a composite model because it could allow you to use a smaller capacity.
You could argue that both of these advantages are purely accounting tricks, results of the rules that we at Microsoft have imposed on how Fabric capacities work, and you’d have a point. But it’s unlikely these rules will change anytime soon.
Is DirectQuery still difficult to manage? Yes, this objection still stands in my opinion. If you need to tune an Import model you need an expert in tuning Import models. They’re rare but they exist – you can call Marco for example or take one of his courses. If you need to tune a composite model like the one I’ve described you need someone who can tune an Import model, someone who can tune a DirectQuery model (which is really rare) and someone who can tune your Fabric Warehouse or SQL Endpoint. You might not have that combination of skills in your team, and if you do then it would make maintenance and development more expensive – which undermines the “DirectQuery is cheaper” argument a bit.
Finally, there are a couple of other important questions that need to be addressed.
I have Databricks, Snowflake or some other database and I’d like to use that instead of Fabric Warehouse or the Lakehouse SQL Endpoint. Is that a good idea? No, and I’m not just saying that because I work on the Fabric team and I want you to believe that Warehouse/SQL Endpoint is faster or better than them. It’s because the underlying architecture of Fabric and the connector that Power BI uses to connect to Fabric Warehouse/SQL Endpoint means that DirectQuery on Warehouse/SQL Endpoint is significantly faster and more scalable, even apart from the performance of the SQL queries themselves. More optimisations are planned to make the “better together” story even more compelling. And no, before anyone suggests it, we’re not deliberately trying to hobble the performance of other, non-Fabric databases – many other Microsoft data sources share the same architectural disadvantages when it comes to DirectQuery as Snowflake and Databricks. And while it is possible to make DirectQuery perform well for any data source, my point is that DirectQuery on Fabric Warehouse is a special case.
Also, much anecdotal evidence suggests that using Power BI in DirectQuery mode on non-Fabric sources can be more expensive than Import mode because you need to pay to use those other sources as well as pay for your Fabric capacity. DirectQuery mode on non-Fabric databases is more expensive in CU terms than DirectQuery on Fabric Warehouse/SQL Endpoint because of those architectural differences I mentioned and I’ve seen it even be more expensive than an Import model in terms of CU consumption. Meanwhile, as I’ve said, for larger volumes DirectQuery on Warehouse/SQL Endpoint can be cheaper than Import mode or Direct Lake.
Are there any other advantages to DirectQuery mode? Yes but maybe not ones you care about. Do you want genuinely dynamic calculated columns? It’s been possible for years with DirectQuery (see here – the example uses KQL but similar things are possible in SQL). One day I’ll get my demo showing how to do proper time zone conversion, handling daylight savings time, in DirectQuery. My colleague Mark Pryce-Maher has a nice demo of calling Fabric AI functions in a DirectQuery model. But these are all niche use cases.
Your size recommendations for when to use DirectQuery above are very vague. Can’t you be more precise? No, because so much depends on the design of your semantic model and reports and the nature of your data. In an ideal world you would still always choose Import mode or Direct Lake mode as your default and only shift to a DirectQuery composite model when necessary but doing that halfway through a project is quite disruptive. If you want to test the performance of Import mode, Direct Lake mode and DirectQuery mode for your project then go ahead, but if you don’t then for the volumes I’m talking about there’s a very good chance DirectQuery is the best option.
Last of all, I need to stress that this recommendation could change in the future. While Fabric Warehouse is getting a lot of improvements and optimisations, so is Direct Lake mode, so the price and performance characteristics of both will change a lot and that means the decision about which one is the best choice for larger data volumes may change too. I promise to update this post if and when that happens.
Quite a few new Dataflows Gen2 features were released recently without much fanfare, but that doesn’t mean they aren’t important. I will take a look at them all in my next few posts; in this first post I’ll look at the ability to disable V-Order on staged data.
As the (very detailed) documentation for this new feature describes, V-Order is a write-time optimisation for the parquet files that underpin the Delta tables that OneLake uses to store data. It slows down writing data to the tables but means that reading data from them, for example in Power BI Direct Lake mode, is much faster. It used to be the case that when you staged data inside a dataflow that data always had V-Order applied; now you have the option to disable V-Order. Disabling V-Order makes staging faster and because staged data is rarely queried more than a few times, disabling V-Order usually improves overall refresh performance.
To test this I created a simple dataflow that connected to a large (5.58GB) CSV file that contained 17.6 million rows of data, staged the data in a query called StageData, then did a group by on that data in a second query called GroupBy.
I turned off Fast Copy and left the “Enable V-Order compression” setting on:
[At the time of writing this post the ability to disable V-Order only works when Fast Copy is not used – I expect this to change in the future]
I refreshed the dataflow and it took 1 minute 59 seconds. The StageData query (where the staging takes place) took 1 minute 31 seconds; the GroupBy query took 12 seconds.
I then disabled V-Order compression for staging:
…and refreshed again. This time overall refresh took 1 minute 32 seconds, the StageData query took 1 minute 13 seconds and the GroupBy query took 7 seconds. While there is always a certain amount of variation in dataflow refresh timings it’s clear that disabling V-Order resulting in staging being about 20 seconds faster with no reduction in performance of the group by transformation on the staged data. So, in this case at least, disabling V-Order was a good thing for refresh performance.
When you decide whether to use staging in a dataflow you have to test to see whether the extra time needed to stage the data is worth it compared to the performance improvements you get by doing transformations on the staged data (which mostly come from those transformations having the opportunity to be folded). Since turning off V-Order makes staging faster it means that staging is more useful and will result in better overall dataflow refresh performance more often.
To finish off my series of posts on concurrent evaluation in Fabric Dataflows Gen2 (see part 1 and part 2) I decided to do some more realistic tests to see how much parallelism I could get. To do this I uploaded 244 identical Excel files containing almost 542000 rows of data each to a SharePoint document library. Excel files are probably the worst-performing file format for dataflows (see here for some tests that show this), while SharePoint is probably the worst-performing place to store data for a dataflow and also has a reputation for throttling applications that make too many requests.
As a baseline I created a Dataflow Gen2 that combined all the data from all the Excel files in the document library and loaded it into a single table in a Fabric Warehouse; I configured this dataflow up so it did not use Partitioned Compute.
Looking at the Recent Runs data for this dataflow I could see that the query that combined the data from all the Excel files took on average 28 minutes 8 seconds to run.
I then created a copy of this dataflow and modified it so that it did use Partitioned Compute. I set the column containing the Excel filename as the partition key which meant that, in theory, the dataflow could read the data from each of the files in parallel. I then refreshed the dataflow with different maximum concurrency settings (see the previous post in this series for how to do this). Here are the results:
Maximum Concurrency
Average Refresh Duration (Minutes:Seconds)
4
18:37
8
9:42
16
5:24
250
5:21
No limit set
5:16
A few interesting things to note:
Refreshes with a maximum concurrency of 4 were significantly faster than the baseline although nowhere near four times faster, possibly because of the overhead introduced by Partitioned Compute, but
Refreshes with a maximum concurrency of 8 were around twice as fast as refreshes with a maximum concurrency of 4, and refreshes with a maximum concurrency of 16 were almost four times as fast
There was no performance gain achieved by setting a maximum concurrency of more than 16
Setting a limit of more than 16 resulted in the same performance as not setting a limit at all
One last thing to mention is that one of the refreshes when no limit was set failed after two minutes. It was difficult to tell why it failed but after downloading the logs and looking through them it seems that SharePoint was returning a 429 Too Many Requests error, which makes sense given that the dataflow was trying to read data from a lot of Excel files at the same time. Given that no data source, especially SharePoint, can be expected to handle an infinite number of parallel requests for data from a dataflow then this is a good example of where too much parallelism can be a bad thing and cause errors, and where it’s important to limit the amount of parallelism inside the dataflow.