Weaving DataOps into Microsoft Fabric – Invoke-DQVTesting
If you are building tests in Power BI and automating those tests in Azure DevOps, there is a good chance that you want to conduct those tests on your local machine. That way you can avoid waiting for the errors to appear in the pipeline, and not waste precious minutes.
If you’re following the DAX Query View Testing Pattern you’ll eventually grow weary clicking on each tab to see if the test cases pass.
Figure 1 - All the tabs to check to run tests. If we could just automate the check…
DataOps Principle - Improve cycle times: We should strive to minimize the time and effort to turn a customers need into an analytic idea, create it in development, release it as a repeatable production process, and finally refactor and reuse that product.
DataOps emphasizes finding ways to develop faster, automate testing, and deliver well-tested features to the customer efficiently. But how?
With the idea of automating tests via Azure DevOps, I’ve setup a PowerShell module called Invoke-DQVTesting. This module can not only run tests against a set of semantic models in a workspace, but also run locally via the command “Invoke-DQVTesting -Local”. Figure 2 provides a high-level process.
Figure 2 - High-level diagram of automated testing with PBIP, Git Integration, and DAX Query View Testing Pattern
Looking at Figure 2, you’ll see we save the Power BI file into the PBIP format.
Then you use Visual Studio Code to install and run the PowerShell module Invoke-DQVTesting using the command “Invoke-DQVTesting -Local”.
When this module runs it will pull the DAX tests from the DAX Query View, find the Power BI Report opened locally and run the tests. When your Power BI file is opened on your machine, an instance of the model runs on localhost and can then be queried.
Finally, the test results are returned and displayed on the Visual Studio Code terminal (see Figure 3).
Figure 3 - Example of Invoke-DQVTesting -Local results
If you would like to see the module in action, I posted a short video on YouTube.
As always, let me know your thoughts on LinkedIn or Twitter/X on the module and ways to improve it.