Under the kover of business intelligence https://sqlkover.com BI, SQL Server and data by Koen Verbeeck Tue, 19 Nov 2024 14:54:16 +0000 en-US hourly 1 https://sqlkover.com/wp-content/uploads/2019/11/cropped-sitelogo-32x32.jpg Under the kover of business intelligence https://sqlkover.com 32 32 Book Review – Microsoft Power BI Performance Best Practices https://sqlkover.com/book-review-microsoft-power-bi-performance-best-practices/ https://sqlkover.com/book-review-microsoft-power-bi-performance-best-practices/#respond Tue, 19 Nov 2024 14:35:33 +0000 https://sqlkover.com/?p=2569 I was asked to do a review of the book Microsoft Power BI Performance Best Practices (Amazon link), which means I got a copy for free. The book is written by Thomas Leblanc and Bhavik Merchant and published by Packt. As the title obviously implicates, the book aims to give you a set of best […]

The post Book Review – Microsoft Power BI Performance Best Practices first appeared on Under the kover of business intelligence.]]>

I was asked to do a review of the book Microsoft Power BI Performance Best Practices (Amazon link), which means I got a copy for free. The book is written by Thomas Leblanc and Bhavik Merchant and published by Packt.

As the title obviously implicates, the book aims to give you a set of best practices regarding Power BI performance, but in the broadest sense possible. The book will not only talk about DAX or that you shouldn’t put too many visuals on one page, but it also explores capacity management, data modelling (star schema all the things!), the benefits of a performance governance framework, DirectQuery & Direct Lake performance, Power Query folding and so on. The book talks about performance in every layer of a Power BI architecture.

With about 320 pages, the book is a compromise between high-level overviews and deep technical content. If you want to know everything about DAX performance tuning, this probably isn’t the book for you (there is a book for that, it’s called The Definitive Guide to DAX and it’s over 700 pages long). However, the book will set you on the right path. It’s an excellent book for people who have a bit of experience in Power BI and who want to deepen their knowledge, or at least want to know what they should take into account regarding performance when they start a new Power BI project.

I think the book is nicely written, it has decent examples and there were definitely some interesting tips that I can use. However, sometimes I could notice the book was written by two different authors. There was some redundant information (for example, the Fabric Capacity Metrics App is explained in two different chapters. On the other hand, that monstrosity needs all the explaining that there can be). There were also some editing mistakes (some typos, some incorrect links and even a section missing). But all in all I enjoyed reading the book.

One thing I would have liked more is additional reading material. Sure, there are links to blog posts or official documentation, but there are no links to other books. Even if some books are the “de facto” standard in the industry (I mean, not a single book of the Italians mentioned in a chapter about DAX?). Only one chapter has a “further reading” section at the end. If the book doesn’t dive deep in the technical details – which again, this is fine, otherwise this book would have been at 2,000 pages – at least provide more reading materials. I was impressed though with the inclusion of some Fabric content, even this is all still quite new and changing very fast.

I’d recommend this book for people who are still somewhat in the start of their Power BI journey, so they know what they can focus on when delivering Power BI project. Seasoned Power BI professionals should know most of the stuff covered in the book, but it’s always nice to have your knowledge confirmed and to plug any holes that might exist.

The post Book Review – Microsoft Power BI Performance Best Practices first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/book-review-microsoft-power-bi-performance-best-practices/feed/ 0
Create a Numbers Table in Power Query https://sqlkover.com/create-a-numbers-table-in-power-query/ https://sqlkover.com/create-a-numbers-table-in-power-query/#respond Fri, 15 Nov 2024 09:49:50 +0000 https://sqlkover.com/?p=2558 This is a quick blog post, mainly so I have the code available if I need it somewhere in the future 🙂 Sometimes you need a numbers table (also called tally table) when you’re working with data. It’s a table with one single integer column that contains incremental numbers (0,1,2,3,4,…). In a database, it’s fairly […]

The post Create a Numbers Table in Power Query first appeared on Under the kover of business intelligence.]]>
This is a quick blog post, mainly so I have the code available if I need it somewhere in the future 🙂

Sometimes you need a numbers table (also called tally table) when you’re working with data. It’s a table with one single integer column that contains incremental numbers (0,1,2,3,4,…). In a database, it’s fairly easy to generate using either cross-joins or a generator function (GENERATE_SERIES in T-SQL). Recently, I needed such a table in Power BI Desktop. Suppose you don’t have a database as a source (or maybe you cannot change the database), so we need to generate this in Power Query. First, add a blank query:

Then you go to the advanced editor, where you paste the following code:

let
    Source =  List.Generate(()=>0, each _ <= 100, each _ + 1),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "NumberCol"}})
in
    #"Renamed Columns"

This will generate a table with 101 rows, starting at 0 and ending with 100.

UPDATE:

I got this reaction from Alex Powers – a Fabric aficionado from Microsoft – on Bluesky:

This means we can replace the first line of the M code with the elegantly simple {0..100}.

The post Create a Numbers Table in Power Query first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/create-a-numbers-table-in-power-query/feed/ 0
Microsoft finally adds Tenant Switcher for Fabric / Power BI https://sqlkover.com/microsoft-finally-adds-tenant-switcher-for-fabric-power-bi/ https://sqlkover.com/microsoft-finally-adds-tenant-switcher-for-fabric-power-bi/#respond Thu, 14 Nov 2024 14:33:16 +0000 https://sqlkover.com/?p=2552 Praise whatever deity you believe in, because it’s finally here, a tenant switcher for Microsoft Fabric (which includes Power BI). A what? Let me explain. When you have a organization with multiple tenants in Azure (also called directories in some products like Azure Devops), or you’re a consultant like me who works with multiple clients […]

The post Microsoft finally adds Tenant Switcher for Fabric / Power BI first appeared on Under the kover of business intelligence.]]>
Praise whatever deity you believe in, because it’s finally here, a tenant switcher for Microsoft Fabric (which includes Power BI). A what? Let me explain. When you have a organization with multiple tenants in Azure (also called directories in some products like Azure Devops), or you’re a consultant like me who works with multiple clients (with each their own tenants), it’s possible that you can log into multiple tenants using the same email address. This can happen if your user account was added as an external user to another tenant.

Suppose you want to log into Azure Data Factory, and you have access to multiple tenants. No problem, you just pick the one you need when you launch Azure Data Studio:

If you’re already logged into another tenant, no problem, you can easily switch as explained in this blog post. You can do the same in the Azure portal (or in other services such as Azure Devops or even Microsoft Teams):

But not in the Power BI Service (or in Microsoft Fabric). Nope. There was no option there to switch tenants. You had to do some awkward work around by adding the tenant ID to the URL. And the problem is even worse in Power BI Desktop. I explain how you can log into another tenant in this blog post. But let us rejoice, because we can now easily switch between tenants in the Power BI Service!

Hoozah! You still have to do the excruciating work around in Power BI Desktop though.

The post Microsoft finally adds Tenant Switcher for Fabric / Power BI first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/microsoft-finally-adds-tenant-switcher-for-fabric-power-bi/feed/ 0
Book Review – Humanizing Data Strategy by Tiankai Feng https://sqlkover.com/book-review-humanizing-data-strategy-by-tiankai-feng/ https://sqlkover.com/book-review-humanizing-data-strategy-by-tiankai-feng/#respond Tue, 12 Nov 2024 14:03:44 +0000 https://sqlkover.com/?p=2546 This book was making its rounds on social media, and the concept seems interesting enough to make me want to read it. It’s a very short book (only 106 pages), but a pleasant read. It focuses on the people side of a data strategy, instead of focusing on technology and tools as sometimes many of […]

The post Book Review – Humanizing Data Strategy by Tiankai Feng first appeared on Under the kover of business intelligence.]]>

This book was making its rounds on social media, and the concept seems interesting enough to make me want to read it. It’s a very short book (only 106 pages), but a pleasant read. It focuses on the people side of a data strategy, instead of focusing on technology and tools as sometimes many of us do.

The author introduces the 5C model: Competence, Collaboration, Communication, Creativity and Conscience. Each “C” gets its own chapter, where the first three make up the bulk of the book.

There are certainly some interesting concepts in the book, such as the follow the pain methodology. You can use it when you interview people when you’re looking for problems your data strategy might solve. People with the biggest pains will be very pleased to work with the data team, as it will mean their pain will be reduced.

The book finishes with a questionnaire, where each topic gets its own set of questions that you can ask yourself or your organization, to assess how well you are implementing the “human side” of your data strategy.

I can definitely recommend this book, as it’s refreshing to read and it’s a nice change of pace from all those technical books.

The post Book Review – Humanizing Data Strategy by Tiankai Feng first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/book-review-humanizing-data-strategy-by-tiankai-feng/feed/ 0
Free webinar – Tackling the Gaps and Islands Problem with T-SQL Window Functions https://sqlkover.com/free-webinar-tackling-the-gaps-and-islands-problem-with-t-sql-window-functions/ https://sqlkover.com/free-webinar-tackling-the-gaps-and-islands-problem-with-t-sql-window-functions/#respond Thu, 31 Oct 2024 09:28:30 +0000 https://sqlkover.com/?p=2543 I’m hosting a free webinar at MSSQLTips.com at the 19th of December 2024, 6PM UTC. The topic is about window functions, something that really interests me and that should be in the toolbox of every season SQL developer. The abstract: The gaps and islands problem is a common problem in data analysis. Some examples are: […]

The post Free webinar – Tackling the Gaps and Islands Problem with T-SQL Window Functions first appeared on Under the kover of business intelligence.]]>
I’m hosting a free webinar at MSSQLTips.com at the 19th of December 2024, 6PM UTC. The topic is about window functions, something that really interests me and that should be in the toolbox of every season SQL developer. The abstract:

The gaps and islands problem is a common problem in data analysis. Some examples are:

  • How long are active periods that my server was running? Or, how long are the periods that the server was down?
  • On average, how long are the billable periods of my consultants?
  • What was the longest stretch of days without rain?

In this session, you’ll be introduced to the powerful concepts of window functions in T-SQL. With a practical use case, the gaps and islands problem is explained and solved. At the end of the session, you should feel confident in using window functions in your own data analyses.

A basic understanding of T-SQL querying concepts is required to follow this session.

I hope to see you there!

MSSQLTips Logo

The post Free webinar – Tackling the Gaps and Islands Problem with T-SQL Window Functions first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/free-webinar-tackling-the-gaps-and-islands-problem-with-t-sql-window-functions/feed/ 0
dataMinds Connect 2024 – Session Materials https://sqlkover.com/dataminds-connect-2024-session-materials/ https://sqlkover.com/dataminds-connect-2024-session-materials/#respond Thu, 10 Oct 2024 10:59:48 +0000 https://sqlkover.com/?p=2540 The slides and scripts for my session “Tackling the Gaps & Islands Problem with T-SQL Window Functions” at dataMinds Connect 2024 can be downloaded from GitHub. If you want to run the sample scripts, some of them require an installation of the AdventureWorks DW sample database.

The post dataMinds Connect 2024 – Session Materials first appeared on Under the kover of business intelligence.]]>
The slides and scripts for my session “Tackling the Gaps & Islands Problem with T-SQL Window Functions” at dataMinds Connect 2024 can be downloaded from GitHub. If you want to run the sample scripts, some of them require an installation of the AdventureWorks DW sample database.

The post dataMinds Connect 2024 – Session Materials first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/dataminds-connect-2024-session-materials/feed/ 0
Connect to Power BI as a Guest User in another Tenant https://sqlkover.com/connect-to-power-bi-as-a-guest-user/ https://sqlkover.com/connect-to-power-bi-as-a-guest-user/#comments Thu, 19 Sep 2024 11:45:54 +0000 https://sqlkover.com/?p=2524 Sometimes your Microsoft Entra ID account (formerly known as Azure Active Directory) is added as a guest user in another tenant. This happens quite a lot when you’re a consultant and your client can’t create a new user in their own tenant, so they add the account of your own company as a guest instead. […]

The post Connect to Power BI as a Guest User in another Tenant first appeared on Under the kover of business intelligence.]]>
Sometimes your Microsoft Entra ID account (formerly known as Azure Active Directory) is added as a guest user in another tenant. This happens quite a lot when you’re a consultant and your client can’t create a new user in their own tenant, so they add the account of your own company as a guest instead. If you’re not a consultant, it can also happen after a merger or acquisition and you’re suddenly stuck with multiple tenants.

Having multiple tenants usually isn’t an issue. In the Azure Portal, it’s easy to switch between multiple organizations (or directories as they’re sometimes called):

You get a list of all organizations you’re account has been added into, and you switch to the one you need.

In Azure Data Factory, you can do the same thing.

However, such an easy switch is not available in Power BI, unfortunately. When you go to https://app.powerbi.com and you log into your account, you will always go to the Power BI service of your own home tenant. So, how do you go to another tenant with your own account? You use this straight-forward, user-friendly (ahem) trick: you add the tenant-ID in the URL. Because every regular user knows their tenant ID, right? Anyway, if you do know it, you just add it to the URL like this:

https://app.powerbi.com/home?ctid=yourtenantID&experience=power-bi

You can find your tenant ID in the Azure Portal on the overview page of Entra ID:

But what about Power BI Desktop? There’s no URL where you can put a tenant ID, and there certainly isn’t an easy button to switch tenant. By default, Power BI Desktop will also connect to your home tenant (especially if you’ve logged in before). To connect to another tenant, you need to follow these steps:

  1. In the top-right corner, click on your name.
  1. Choose to switch to another account.
  1. You will get a non-helpful window where you need to enter your e-mail address. Since the address is the same in all the tenants, this is not going to help you any further. You need to get to the “real” login screen where you have multiple options to log in. To get there, you can enter an e-mail that won’t work or isn’t associated with any of the tenants.
  1. This will take you to the login screen you need. Click on Use another account.
  1. This will give a login screen with no email address entered yet. However, you cannot enter your email address just yet, because that will take you – again – to your home tenant. Instead, choose Sign-in options.
  1. This will finally give you the option to specify another tenant.
  1. Unfortunately, no handy drop-down like in any other service; you need to enter the name of the tenant manually. Don’t make a mistake, because you’ll get an error and choosing an organization will be gone from the sign-in options, meaning you can start over from scratch.
  1. After entering the tenant you need, you can specify your own e-mail again, but instead of your home tenant you will log into the tenant you just specified. Hoozah.

If you think this is quite cumbersome and not that user-friendly, please upvote the following idea: Switch accounts and tenants in the portal in the same way as Azure.

The post Connect to Power BI as a Guest User in another Tenant first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/connect-to-power-bi-as-a-guest-user/feed/ 1
How to use a Script Activity in ADF as a Lookup https://sqlkover.com/how-to-use-a-script-activity-in-adf-as-a-lookup/ https://sqlkover.com/how-to-use-a-script-activity-in-adf-as-a-lookup/#respond Thu, 27 Jun 2024 11:28:17 +0000 https://sqlkover.com/?p=2515 In Azure Data Factory (ADF, but also Synapse Pipelines and Fabric Pipelines), you have a typical scenario where you retrieve some metadata from a database and then loop over the metadata with a ForEach activity. For example, to copy all the table from a source database in a metadata-driven pipeline. The obvious choice would be […]

The post How to use a Script Activity in ADF as a Lookup first appeared on Under the kover of business intelligence.]]>
In Azure Data Factory (ADF, but also Synapse Pipelines and Fabric Pipelines), you have a typical scenario where you retrieve some metadata from a database and then loop over the metadata with a ForEach activity. For example, to copy all the table from a source database in a metadata-driven pipeline. The obvious choice would be to use the Lookup activity. But the Script activity might also be a good choice in certain scenarios. The Microsoft blog post Execute SQL statements using the new ‘Script’ activity in Azure Data Factory and Synapse Pipelines gives a good comparison between the two:

Screenshot taken from the blog post

The biggest advantage for the Lookup is that it supports all data sources, while the Script activity only supports databases (aka stuff that can deal with SQL). The Script activity on the other hand can execute multiple statements which might save you the effort of configuring multiple activities.

The biggest downside of the Lookup is that this the default:

However, there’s also another downside of the Lookup which isn’t mentioned: it can only return max 5000 rows. Do you really want to loop over 5000 items in ADF, probably not. But let’s suppose you do, then the Script activity is your savior.

How do we use it as a Lookup? Configure your query as normal, and make sure there’s at least one SELECT statement in there that actually returns data.

When you run the activity, you’ll get JSON output like this:

You’ll get a count of how many result sets are returned, along with an array called resultSets. Each result set has a row count, and another array called rows. To loop over the rows of a specific result set, you can use the following expression in a ForEach:

@activity('myScriptActivity').output.resultSets[0].rows

If you only have one result set, you take the index 0 of the resultSets array. If you need the second, you use 1, and so on. And that’s it, you are now using a Script activity instead of a Lookup.

The post How to use a Script Activity in ADF as a Lookup first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/how-to-use-a-script-activity-in-adf-as-a-lookup/feed/ 0
Database Build Error – Incorrect syntax near DISTINCT https://sqlkover.com/database-build-error-incorrect-syntax-near-distinct/ https://sqlkover.com/database-build-error-incorrect-syntax-near-distinct/#respond Mon, 24 Jun 2024 14:35:22 +0000 https://sqlkover.com/?p=2509 I wrote a piece of SQL that had some new T-SQL syntax in it: IS DISTINCT FROM. This predicate checks if two expressions are equal taking NULL into account. I successfully ran the code on an Azure SQL Database. However, when I tried to deploy the code using an Azure Devops pipeline, it returned the […]

The post Database Build Error – Incorrect syntax near DISTINCT first appeared on Under the kover of business intelligence.]]>
I wrote a piece of SQL that had some new T-SQL syntax in it: IS DISTINCT FROM. This predicate checks if two expressions are equal taking NULL into account. I successfully ran the code on an Azure SQL Database. However, when I tried to deploy the code using an Azure Devops pipeline, it returned the following error:

Error SQL46010: Incorrect syntax near DISTINCT.

That’s weird, it didn’t error out in SSMS or in Visual Studio (SQL Server Data Tools). I opened SSDT and rebuild the project. No build errors.

I went to the pipeline in Azure Devops and triggered it again. It completed successfully. That’s even more weird. After some trial and error, I found the culprit. When you trigger a pipeline manually, you get the following dialog:

The agent specification had windows-2019 (it’s been a while since I created the pipeline) and I had changed it to windows-latest.

When taking the latest version of Windows (and probably a more recent version of MSBuild), the error doesn’t occur. Probably the 2019 version doesn’t know about IS DISTINCT FROM, as it was released in 2022.

Conclusion: make sure to use either the latest version, or a recent stable version.

The post Database Build Error – Incorrect syntax near DISTINCT first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/database-build-error-incorrect-syntax-near-distinct/feed/ 0
Speaking at dataMinds Connect 2024 https://sqlkover.com/speaking-at-dataminds-connect-2024/ https://sqlkover.com/speaking-at-dataminds-connect-2024/#respond Mon, 17 Jun 2024 06:34:15 +0000 https://sqlkover.com/?p=2504 I’m very excited to announce I’ve been selected as a speaker for dataMinds Connect 2024, Belgium’s (and maybe/probably/most likely mainland Europe’s) best and greatest Microsoft data platform conference. My session is about a topic I really love: writing window functions in T-SQL. Tackling the Gaps & Islands Problem with T-SQL Window Functions The gaps & […]

The post Speaking at dataMinds Connect 2024 first appeared on Under the kover of business intelligence.]]>
I’m very excited to announce I’ve been selected as a speaker for dataMinds Connect 2024, Belgium’s (and maybe/probably/most likely mainland Europe’s) best and greatest Microsoft data platform conference. My session is about a topic I really love: writing window functions in T-SQL.

Tackling the Gaps & Islands Problem with T-SQL Window Functions

The gaps & islands problem is a common problem in data analysis. Some examples are:
* how long are active periods that my server was running? Or, how long are the periods that the server was down?
* on average, how long are the billable periods of my consultants?
* what was the longest stretch of days without rain?

In this session, you’ll be introduced to the powerful concepts of window functions in T-SQL. With a practical use case, the gaps & islands problem is explained and solved. At the end of the session, you should feel confident in using window functions in your own data analyses.

A basic understanding of T-SQL querying concepts is required to follow this session.

This year’s edition is going to be quite special, not only because it’s my 13th time presenting there, but also because it’s the first time the conference is going to be 3 days long! That’s right, 3 days (1 day precon + 2 days conference) of data platform goodness. I’m also excited because my colleague Andreas Geysegoms gets to present in the newcomer track about dbt & Fabric (and I’m his mentor!), but also because our company AE is a sponsor.

Many awesome things to look forward to. The agenda is already online and as usual, it’s phenomenal. Hope to see you there in Mechelen, at October 7th till the 9th. You can register here.

The post Speaking at dataMinds Connect 2024 first appeared on Under the kover of business intelligence.]]>
https://sqlkover.com/speaking-at-dataminds-connect-2024/feed/ 0