Microsoft fabric free; Fabric free trial

Should I Upgrade to a free Microsoft Fabric Trial?

If you are exploring Microsoft Fabric and encounter the message “Upgrade to a free Microsoft Fabric Trial” despite already having workspace capacity, here’s what you need to know. This common confusion happens because certain Microsoft Fabric features, especially preview ones like SQL databases and AI Skills, require tenant-level preview feature enablement—even if your workspace is already on a Premium or Fabric capacity.

Why Does Microsoft Fabric Ask for a Free Trial?

When trying to create a SQL database or an AI skill (preview) inside Microsoft Fabric, some users see a prompt requiring them to “Upgrade to a free Microsoft Fabric Trial.” This happens because these preview features are disabled by default at the tenant level for the entire organization. Even if your workspace has an assigned capacity (Premium or Fabric), you need administrator privileges to explicitly enable these preview features.

How to Enable Microsoft Fabric Preview Features

If you are an admin, here’s what to do:

  1. Go to the Microsoft Fabric admin portal.

  2. Look for tenant settings related to preview features.

  3. Enable SQL Database (preview) and AI Skills (preview).

  4. Wait a few minutes (usually between 3 to 15 minutes) for the changes to take effect.

After enabling these settings, you can create a SQL database or AI skill in your workspace without the need to upgrade or start a new trial.

This step is essential because Microsoft Fabric treats these preview features separately from your existing capacity licensing. The message asking to upgrade to a free trial is somewhat misleading—it really means “You need tenant-level preview feature enablement.” This key insight was highlighted by Adam Saxton from Guy in a Cube in his video explanation.

Quick Links to Get Started with Microsoft Fabric Features

Summary and Best Practices

  • Microsoft Fabric preview features like SQL databases and AI Skills require explicit tenant enablement.

  • Even if you have Premium or Fabric capacity, these features are disabled by default for your organization.

  • Admins must enable preview features in the admin portal for users to access them.

  • The free Fabric trial message is a prompt triggered due to disabled preview features, not an actual lack of capacity.

  • After enabling the settings, wait a few minutes before the features become available.


By understanding this distinction, you can avoid confusion and start leveraging Microsoft Fabric’s powerful capabilities without unnecessary trial upgrades. For more tips and updates on Microsoft Fabric and Power BI, follow the community experts and stay tuned for new videos and tutorials.

keywords: Microsoft Fabric freeMicrosoft Fabric trialMicrosoft Fabric preview features, and Microsoft Fabric SQL database.

Feel free to share your questions or experiences with Microsoft Fabric preview features in the comments!

If you’re ready to dive deep into Microsoft Fabric and its rich capabilities, start creating your first SQL database or AI skill today using the official docs linked above. Unlock the full potential of your data analytics journey!

 

 

 

 

Excel Export to PDF with Gridlines

Excel Export to PDF with Gridlines and Row & Column Labels

How to Excel Export to PDF with Gridlines and Labels: A Quick Tutorial

Mastering an Excel export to PDF with gridlines and labels is a useful skill when you want your reports to be clear and easy to read—whether you’re sharing financial tables or audit logs with your team. By default, Excel doesn’t always include gridlines, row numbers, or column letters when exporting to PDF, so here’s how to make sure they’re included in your output.

Why Use Gridlines and Labels in Your PDF Exports?

  • Gridlines help visually separate data, preventing confusion and making numbers easier to follow.

  • Row and column labels (like “A, B, C…” and “1, 2, 3…”) make referencing specific data much easier for you and your colleagues.

Combining these can make your exported PDFs clearer, more professional, and easier to audit or review.

Step-by-Step Guide: Excel Export to PDF with Gridlines and Labels

  1. Open Your Worksheet in Excel

  2. Make sure your data is organized the way you want it to appear in the PDF.

  3. Enable Gridlines for Printing

    • Go to the Page Layout tab.

    • In the Sheet Options group, under Gridlines, check the box labeled Print.

    • This ensures Excel will include gridlines when you export or print.

  4. Enable Row and Column Headers (Labels)

    • Still on the Page Layout tab, find the option labeled Headings right next to Gridlines.

    • Make sure the Print checkbox for Headings is also checked.

    • This tells Excel to include the column letters (A, B, C…) and row numbers (1, 2, 3…) on the output.


  5. Adjust the Print Area If Needed

    • Highlight the section of your worksheet you want exported.

    • Go to Page Layout > Print Area > Set Print Area to limit the export to your chosen data.

  6. Preview Before Exporting

    • Go to File > Print or press Ctrl + P for a preview.

    • Double-check that both gridlines and labels are visible in the preview.

  7. Export to PDF

    • Click File > Export > Create PDF/XPS Document or select File > Save As and choose PDF.

    • Confirm your settings and save your file.

That’s it! Now you’ve created an Excel export to PDF with gridlines and labels, making your output highly readable and reference-friendly.

Tips for a Perfect Excel Export to PDF with Gridlines and Labels

  • If you want only some of the sheet to appear, use the Print Area feature.

  • For large tables, consider using the “Repeat Rows at Top” or “Repeat Columns at Left” options under Page Layout > Print Titles so that headers are included on every page.

  • If gridlines look faint, you can adjust their color for better visibility via File > Options > Advanced > Display options for this worksheet > Gridline color.

  • Always preview before you export to avoid surprises!

Conclusion:
Follow these steps for a professional Excel export to PDF with gridlines and labels every time. This makes your data easier to reference, looks more polished, and helps your audience zero in on the right cells in your reports.

If you have other Excel PDF export challenges or want to learn about advanced print setups, let me know in the comments!


Do You Need Personalized Help and Custom Solutions?

I have been called a guru and hero more times than I can count, as I am a great listener and truly have a knack for asking the right questions to understand unique business challenges. I am very passionate about crafting tools and processes that work for users of all levels and experience. 

Reach out today and let’s discuss how I can help you and your business!

 

I also offer one-on-one tutoring for customized learning and upskilling. Visit my consulting page and send a message if you are interested.

 

Other Resources

Also, consider checking out some great resources on Amazon Disclosure: this is an affiliate link, so I may earn a small commission if you decide to make a purchase which will help cover the cost of hosting this website. 

Please bookmark and subscribe!  I am actively working on adding new, relevant content to help others out! Thanks so much!

Subscribe via Email and Stay Up to Date!

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

If I helped you, please consider leaving a tip via PayPal to support the blog! Thanks!!

Thanks so much for supporting my blog and for helping others too!

keywords to help others find this post:

#ExcelTips #PDFExport #GridLines #ExcelTutorial 
Excel PDF export grid lines missing
Excel Page Layout tab settings for PDF export
Excel Page Setup dialog launcher
How to show grid lines in Excel PDF
Excel Sheet tab settings for PDF export
Export Excel file to PDF with grid lines
Excel PDF export row and column headings
Retain grid lines in Excel PDF export
Excel tutorial for PDF export settings
Excel tips for polished PDF exports

VBA With Power Query: Maximize Efficiency and Automate Your Data Processes in Excel (with VBA code)

What are the benefits of using VBA with Power Query?

Using VBA in conjunction with Power Query can provide significant benefits, especially when you need to automate complex workflows, integrate data from multiple sources, or perform advanced transformations programmatically. Here are the key benefits of using VBA over just using Power Query directly:

  1. Automation and Repetition:
    • Automation: VBA allows you to automate repetitive tasks, such as importing data from multiple files, applying the same transformations, and saving the results in a consistent format.
    • Scheduling: You can schedule VBA macros to run at specific times, ensuring data is updated automatically.
  2. Customization and Flexibility:
    • Custom Functions: VBA enables you to create custom functions and procedures that can be used within Power Query M code.
    • Dynamic Parameters: You can pass dynamic parameters to Power Query queries using VBA, allowing for more flexible data processing. This alone is a huge benefit!!
  3. Integration with Other Applications:
    • Interoperability: VBA can interact with other applications and services, such as databases, web APIs, and email clients, enhancing the capabilities of Power Query.
    • Data Export: You can use VBA to export data to various formats, such as PDF, CSV, or other Excel files, after it has been processed by Power Query.
  4. Complex Logic and Control:
    • Conditional Logic: VBA provides powerful conditional logic and control structures that can be used to handle complex data processing tasks.
    • Error Handling: You can implement robust error handling in VBA to manage unexpected issues during data processing.
  5. User Interface:
    • Custom UserForms: VBA allows you to create custom user interfaces (UserForms) for data entry and interaction, making it easier for users to perform complex tasks without needing to know Power Query M code.
    • Buttons and Macros: You can add buttons and macros to Excel worksheets to trigger VBA scripts, making it user-friendly.
  6. Advanced Data Manipulation:
    • Data Cleaning: VBA can be used for advanced data cleaning tasks, such as removing specific patterns, handling missing data, and normalizing data formats.
    • Data Transformation: VBA can perform complex transformations that might be difficult or impossible to achieve with Power Query alone.
  7. Version Control and Collaboration:
    • Version Control: VBA code can be version-controlled using tools like Git, allowing for better collaboration and tracking changes.
    • Shared Macros: You can share VBA macros with your team, ensuring consistency in data processing workflows. This can be especially helpful for vacation coverage or spreading the workload among multiple team members!
  8. Performance Optimization:
    • Efficiency: For large datasets, VBA can be more efficient in certain scenarios, especially when combined with Power Query for initial data loading and filtering.
    • Resource Management: VBA can manage system resources more effectively, ensuring smooth performance during data processing.

When to Use VBA Over Power Query

  • Complex Workflows: When you need to perform a series of complex transformations and data manipulations that are difficult to achieve with Power Query alone.
  • Integration with Other Systems: When you need to integrate Excel with other applications, databases, or web services.
  • Automated Reporting: When you need to automate the generation of reports and dashboards based on dynamic data sources.
  • Custom User Interfaces: When you need to create custom user interfaces for data entry and interaction.
  • Advanced Error Handling: When you need robust error handling and logging for data processing tasks.

When to Use Power Query Alone

  • Simple Data Transformation: When you need to perform simple data transformations and cleaning tasks.
  • Data Visualization: When you need to create dynamic data visualizations and dashboards.
  • Data Integration: When you need to integrate and combine data from multiple sources without complex logic.
  • Data Refresh: When you need to refresh data regularly from external sources.
  • Data Transformation: Power Query allows for complex data transformations, such as filtering, merging, and aggregating data.
  • Refreshable Data: Data imported using Power Query can be easily refreshed to update with new data.
  • Scalability: Power Query is better suited for larger datasets and more complex data processing tasks.

VBA with Power Query Code Samples with Explanations

Use Case: Importing Data from CSV Files Using Power Query

Power Query is a more advanced and flexible tool for data import and transformation in Excel. It allows for more complex data transformations and can handle larger datasets more efficiently. Here’s how you can use VBA to import a CSV file using VBA with Power Query.


Sub ImportCSVWithPowerQuery()
Dim filePath As String
Dim connName As String

filePath = "C:\Data\sales_data.csv"
connName = "SalesDataConnection"

' Check if the connection already exists and delete it
On Error Resume Next
ThisWorkbook.Queries.Delete connName
On Error GoTo 0

' Create a new Power Query connection
With ThisWorkbook.Queries.Add(Name:=connName, Formula:= _
    "let" & vbCrLf & _
    "    Source = Csv.Document(File.Contents(""" & filePath & """),[Delimiter="","", Columns=11, Encoding=65001, QuoteStyle=QuoteStyle.Csv])," & vbCrLf & _
    "    PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars=true])" & vbCrLf & _
    "in" & vbCrLf & _
    "    PromotedHeaders")

    ' Load the query into a new worksheet
    With ThisWorkbook.Worksheets.Add
        .Name = "Data"
        .Cells(1, 1).LoadFromText Connection:=connName, Destination:=.Cells(1, 1)
    End With
End With

End Sub

Explanation of Power Query VBA Code

  1. File Path and Connection Name:
    • filePath is the path to your CSV file
    • connName is the name of the Power Query connection.
  2. Delete Existing Connection:
    • The code checks if the connection already exists and deletes it to avoid conflicts.
  3. Create New Power Query Connection:
    • The Queries.Add method creates a new Power Query connection.
    • The Formula parameter specifies the Power Query M code to import and transform the CSV file.
  4. Load Query into Worksheet:
    • A new worksheet is created, and the query is loaded into it using LoadFromText

Use Case: Importing and Transforming Data from an Excel File Using Power Query and VBA

Objective: Import data from a specific worksheet in an Excel file, filter out rows with specific criteria, perform some transformations, and load the cleaned data into a new worksheet.

Preparation:

  1. Prepare the Source Excel File:
    • Ensure your source Excel file is located at a known path, e.g., C:\Data\source_data.xlsx.
    • Ensure the data is in a worksheet named SalesData.
  2. VBA Code to Import and Transform Data Using Power Query:
Sub ImportAndTransformExcelDataWithPowerQuery()
    Dim sourceFilePath As String
    Dim sourceWorkbookName As String
    Dim sourceSheetName As String
    Dim connName As String
    Dim queryName As String
    Dim ws As Worksheet
    
    ' Set file path, workbook name, sheet name, and connection/query names
    sourceFilePath = "C:\Data\source_data.xlsx"
    sourceWorkbookName = "source_data.xlsx"
    sourceSheetName = "SalesData"
    connName = "SourceDataConnection"
    queryName = "TransformedSalesData"
    
    ' Delete existing connection and query if they exist
    On Error Resume Next
    ThisWorkbook.Queries.Delete connName
    ThisWorkbook.Queries.Delete queryName
    On Error GoTo 0
    
    ' Create a new Power Query connection
    ThisWorkbook.Queries.Add Name:=connName, Formula:= _
        "let" & vbCrLf & _
        "    Source = Excel.Workbook(File.Contents(""" & sourceFilePath & """), null, true)," & vbCrLf & _
        "    SalesData_Sheet = Source{[Item=""" & sourceSheetName & """,Kind=""Sheet""]}[Data]" & vbCrLf & _
        "in" & vbCrLf & _
        "    SalesData_Sheet"
    
    ' Create a new Power Query query for transformation
    ThisWorkbook.Queries.Add Name:=queryName, Formula:= _
        "let" & vbCrLf & _
        "    Source = #" & connName & "," & vbCrLf & _
        "    RemovedTopRows = Table.Skip(Source, 1)," & vbCrLf & _
        "    RemovedDuplicates = Table.Distinct(RemovedTopRows, {" & _
        "        ""Product"", ""Region"", ""Sales"", ""Date"", ""Quantity"", ""Category""})," & vbCrLf & _
        "    FilteredRows = Table.SelectRows(RemovedDuplicates, each [Sales] > 100)," & vbCrLf & _
        "    SortedRows = Table.Sort(FilteredRows,{{""Date"", Order.Ascending}})," & vbCrLf & _
        "    AddedTotalSales = Table.AddColumn(SortedRows, ""TotalSales"", each [Sales] * [Quantity], Int64.Type)" & vbCrLf & _
        "in" & vbCrLf & _
        "    AddedTotalSales"
    
    ' Load the transformed query into a new worksheet
    Set ws = ThisWorkbook.Worksheets.Add
    ws.Name = "TransformedData"
    ws.Cells(1, 1).LoadFromText Connection:=queryName, Destination:=ws.Cells(1, 1)
    
    ' Format the worksheet
    With ws
        .Range("A1").CurrentRegion.AutoFit
        .Range("A1").CurrentRegion.Style = "TableStyleMedium9"
    End With
    
    MsgBox "Data imported and transformed successfully!"
End Sub

Explanation of the VBA Code

  1. Set File Path, Workbook Name, Sheet Name, and Names:
    • sourceFilePath is the path to your source Excel file.
    • sourceWorkbookName is the name of the source Excel file.
    • sourceSheetName is the name of the worksheet containing the data.
    • connName is the name of the initial Power Query connection.
    • queryName is the name of the transformed Power Query query.
  2. Delete Existing Connection and Query:
    • The code checks if the connection and query already exist and deletes them to avoid conflicts.
  3. Create a New Power Query Connection:
    • The Queries.Add method creates a new Power Query connection to import data from the specified worksheet in the Excel file.
    • The Formula parameter specifies the Power Query M code to import the data.
  4. Create a New Power Query Query for Transformation:
    • This query uses the initial connection as its source.
    • It skips the first row (assuming headers).
    • It removes duplicates based on specified columns.
    • It filters rows where Sales is greater than 100.
    • It sorts the filtered rows by Date in ascending order.
    • It adds a new column TotalSales calculated as Sales * Quantity.
  5. Load the Transformed Query into a New Worksheet:
    • A new worksheet is created, and the transformed query is loaded into it using LoadFromText.
  6. Format the Worksheet:
    • The code automatically fits the columns and applies a table style for better readability.

Detailed Steps

  1. Prepare the Source Excel File:
    • Update the path to match your source Excel file.
    • Ensure the data is in a worksheet named SalesData, or update that variable to match your data.
  2. Open VBA Editor:
    • Press Alt + F11 to open the VBA editor.
  3. Insert a New Module:
    • In the VBA editor, go to Insert > Module to create a new module.
  4. Copy and Paste the VBA Code:
    • Copy the above VBA code and paste it into the module.
  5. Run the Macro:
    • Close the VBA editor and return to Excel.
    • Press Alt + F8, select ImportAndTransformExcelDataWithPowerQuery, and click Run.
  6. View the Results:
    • A new worksheet named TransformedData will be created, showing the imported and transformed data.

Additional Tips

  • Customizing Columns:
    • You can customize the column names and the criteria for filtering and sorting based on your specific dataset.
  • Handling Different Workbooks and Sheets:
    • Adjust the sourceFilePath, sourceWorkbookName, and sourceSheetName variables to match your source file and worksheet.
  • Error Handling:
    • Add error handling to manage potential issues, such as file not found or invalid data.

Example: Combining VBA with Power Query for Automation of Reporting

Here’s a more detailed example that combines VBA with Power Query to automate a complex data processing workflow that can automate data reporting from start to finish, including transforming the data and outputting a user-friendly report.

Use Case: Automating Data Import, Transformation, and Reporting

Objective: Import data from multiple Excel files, perform transformations, and generate a consolidated report.

VBA Code:

Sub AutomateDataProcessing()
    Dim folderPath As String
    Dim fileName As String
    Dim connName As String
    Dim queryName As String
    Dim ws As Worksheet
    Dim lastRow As Long
    
    ' Set folder path and connection/query names
    folderPath = "C:\Data\"
    connName = "SourceDataConnection"
    queryName = "TransformedSalesData"
    
    ' Delete existing connection and query if they exist
    On Error Resume Next
    ThisWorkbook.Queries.Delete connName
    ThisWorkbook.Queries.Delete queryName
    On Error GoTo 0
    
    ' Initialize a new worksheet for consolidated data
    Set ws = ThisWorkbook.Worksheets.Add
    ws.Name = "ConsolidatedData"
    ws.Range("A1").Value = "Product"
    ws.Range("B1").Value = "Region"
    ws.Range("C1").Value = "Sales"
    ws.Range("D1").Value = "Date"
    ws.Range("E1").Value = "Quantity"
    ws.Range("F1").Value = "Category"
    ws.Range("G1").Value = "TotalSales"
    
    ' Loop through all Excel files in the folder
    fileName = Dir(folderPath & "*.xlsx")
    Do While fileName <> ""
        ' Create a new Power Query connection for each file
        ThisWorkbook.Queries.Add Name:=connName, Formula:= _
            "let" & vbCrLf & _
            "    Source = Excel.Workbook(File.Contents(""" & folderPath & fileName & """), null, true)," & vbCrLf & _
            "    SalesData_Sheet = Source{[Item=""SalesData"",Kind=""Sheet""]}[Data]" & vbCrLf & _
            "in" & vbCrLf & _
            "    SalesData_Sheet"
        
        ' Create a new Power Query query for transformation
        ThisWorkbook.Queries.Add Name:=queryName, Formula:= _
            "let" & vbCrLf & _
            "    Source = #" & connName & "," & vbCrLf & _
            "    RemovedTopRows = Table.Skip(Source, 1)," & vbCrLf & _
            "    RemovedDuplicates = Table.Distinct(RemovedTopRows, {" & _
            "        ""Product"", ""Region"", ""Sales"", ""Date"", ""Quantity"", ""Category""})," & vbCrLf & _
            "    FilteredRows = Table.SelectRows(RemovedDuplicates, each [Sales] > 100)," & vbCrLf & _
            "    SortedRows = Table.Sort(FilteredRows,{{""Date"", Order.Ascending}})," & vbCrLf & _
            "    AddedTotalSales = Table.AddColumn(SortedRows, ""TotalSales"", each [Sales] * [Quantity], Int64.Type)" & vbCrLf & _
            "in" & vbCrLf & _
            "    AddedTotalSales"
        
        ' Load the transformed query into the consolidated worksheet
        lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
        ws.Cells(lastRow + 1, 1).LoadFromText Connection:=queryName, Destination:=ws.Cells(lastRow + 1, 1)
        
        ' Delete the Power Query connection and query after processing
        ThisWorkbook.Queries.Delete connName
        ThisWorkbook.Queries.Delete queryName
        
        ' Move to the next file
        fileName = Dir
    Loop
    
    ' Format the worksheet
    With ws
        .Range("A1").CurrentRegion.AutoFit
        .Range("A1").CurrentRegion.Style = "TableStyleMedium9"
    End With
    
    MsgBox "Data imported, transformed, and consolidated successfully!"
End Sub

Explanation of the VBA Code

  1. Set Folder Path and Names:
    • folderPath is the path to the folder containing the Excel files.
    • connName is the name of the initial Power Query connection.
    • queryName is the name of the transformed Power Query query.
  2. Delete Existing Connection and Query:
    • The code checks if the connection and query already exist and deletes them to avoid conflicts.
  3. Initialize a New Worksheet:
    • A new worksheet named ConsolidatedData is created to store the consolidated data.
  4. Loop Through Excel Files:
    • The code loops through all Excel files in the specified folder.
    • For each file, it creates a new Power Query connection to import data from the SalesData worksheet.
  5. Create a New Power Query Query for Transformation:
    • This query uses the initial connection as its source.
    • It skips the first row (assuming headers).
    • It removes duplicates based on specified columns.
    • It filters rows where Sales is greater than 100.
    • It sorts the filtered rows by Date in ascending order.
    • It adds a new column TotalSales calculated as Sales * Quantity.
  6. Load the Transformed Query into the Consolidated Worksheet:
    • The transformed data is loaded into the ConsolidatedData worksheet.
  7. Delete the Power Query Connection and Query:
    • After processing each file, the connection and query are deleted to clean up.
  8. Format the Worksheet:
    • The code automatically fits the columns and applies a table style for better readability.

Conclusion

Using VBA in conjunction with Power Query provides a powerful combination for automating and managing complex data workflows. While Power Query is excellent for data transformation and integration, VBA offers the flexibility and control needed for advanced automation and integration tasks. By combining these tools, you can create robust and efficient data processing solutions.

Feel free to comment other examples you would like to see as we continue to explore automation of workflows via both VBA and Power Query!

Solution for Power BI Refresh Error in the Web Service

Web Service Power BI Refresh Error When Trying to Refresh On Premises 32-bit Database/Source

I recently worked with a client who is still using an old 32-bit Oracle instance with lots of dependencies. Upgrading is not currently an option. In her Power BI report/model, she is querying several tables in the Oracle database. Unfortunately due to the 32-bit architecture she was not able to schedule her refreshes, even using the desktop gateway.

The Power BI refresh error she received was “Failed to update data source credentials: An error happened while reading data from the provider: ‘Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.'”

Workaround for Power BI Refresh Error in Web Service When Trying to Refresh On Premises 32-bit
Power BI Architecture Error

As a result, she found she could only refresh this report using the Power BI desktop client. She would then manually publish to the cloud. This was cumbersome as the data refresh took quite some time, and she needed it done daily. I came up with two solutions for her, both of which we implemented and tried. One proved to better for us, and ultimately she is successfully using this first solution/workaround that I will cover.

Solution #1Export Query Results to CSV and Post on SharePoint

  • So just as the title of the section states, the final workaround was for us to automate the generation of CSV files to ultimately be consumed by Power Query.
  • We did this by using a combination of scripts pulling data via SQL in VBA (Access, Excel) and via SQL in Python. You can pull the data any way you are most comfortable (macros, etc.).
  • The query results are then outputted to the CSV files, which are written directly to SharePoint folders.
  • After all this was set up and the initial files were changed, we then changed the source of the data in Power Query, to now navigate to SharePoint folders and then process the CSV files.
  • It is important to note that you are not required to use CSV files. These made sense in our case due to the amount of data we were working with (generating several very large files nightly). You can write to any supported file format if that works better in your case, as long as you can place it on SharePoint and Power Query can process it.
  • Also as noted we used a separate folder for each unique query. If you are also replacing several queries, you can either do this (write to separate folders) or if you would prefer just one, then utilize different naming convention patterns to filter.
  • Everything is then kicked off via a command line batch script (.bat) using the Windows task scheduler on her desktop to run overnight. We also set up the same script on a colleague’s PC as a backup/for redundancy in case something were to happen, but it is not actively running.
  • After refreshing and publishing the updated report with the new SharePoint sources, I then went into settings in the Web Service and added the credentials there for SharePoint. I saved and kicked off the refresh in the browser.
  • The refresh was successful, so I then set a daily schedule for the web service to refresh automatically. No intervention has been needed since implementation!

Solution #2 – Automate the Power BI Desktop Refresh Process Using Python

  • This method is much less convenient in my opinion, as after it had been implemented, it failed often and required manual intervention several times before we moved on to the other solution.
  • Another caveat is that this solution requires the user to have at least some familiarity with Python (or finding someone with Python knowledge to tap as a support resource).
  • Also, obviously someone needs to install Python, the required package and then set up the automation to run the scripts.
  • Important note – it is possible to install a portable version of Python if you do not have admin rights on the desktop.
  • The package is called pbixrefresher (repo is linked).
  • This gentleman does a great job of walking through setting it up in his YouTube video about it: https://youtu.be/wtXXpicCUlY

I hope this post has been helpful and has maybe given you some ideas on how to proceed if you or an organization you are supporting is facing this same situation with older data sources. Also, I’d love to hear about other solutions if you’ve faced the same issue and handled it differently.

Please reach out with any questions or if you would like to see further coverage of any of the concepts/steps mentioned in this post. I am also available on a limited basis for consulting as my schedule is full as of late (a good thing!). Just fill out the contact form and I will get back to you.

Organize your DAX measures

How To Organize Your DAX Measures in Power BI Folders and Make Finding Them A Breeze

As you progress in Power BI, you will gradually be working with more DAX measures and calculations. As a result, things can easily get cluttered. Today you will learn a few valuable tips and tricks on how to organize your DAX measures for a more efficient workflow. Hopefully this will help you and become a standard practice!

Watch the video for step by step instructions and a full explanation.

To summarize, Reid shows us how to add a new table and move our measures to it so they are together in one place.

He then shows us how to convert this into a folder, and then subsequently create subfolders to further organize your DAX measures in the model. Reid continues on to show us how we can have a measure in multiple locations if it makes sense.

What a great way to manage the measures as they grow in number!

***** Video Details *****
00:00 Introduction
00:33 Root folders
01:32 Subfolders
03:30 Actual Amount VTB

***** Learning Power BI? *****
FREE COURSE – Ultimate Beginners Guide To Power BI – http://portal.enterprisedna.co/p/ultimate-beginners-guide-to-power-bi
FREE COURSE – Ultimate Beginners Guide To DAX – http://portal.enterprisedna.co/p/ultimate-beginners-guide-to-dax
FREE – Power BI Resources – http://enterprisedna.co/power-bi-resources
FREE – 60 Page DAX Reference Guide Download – https://enterprisedna.co/dax-formula-reference-guide-download/
Enterprise DNA Membership – https://enterprisedna.co/membership
Enterprise DNA Online – http://portal.enterprisedna.co/
Enterprise DNA Events – https://enterprisedna.co/enterprise-dna-events-page/

#EnterpriseDNA #PowerBI #PowerBIDesktop #PowerBITutorial #DAX #DAXTutorial

rank in Access

Solved: Pass a Parameter to a SQL Query in Power Query

I’ve done a fair amount of research around dynamic and parameterized queries, specifically around an Excel query parameter, as in trying to pass a parameter to a SQL query in Power Query.  Here’s the very quick and easy way to do this!

This exact solution works in Excel. Creating a dynamic SQL query with a parameter in Excel allows for amazing flexibility. The use cases are endless and can benefit so many types of Excel work across industries – if you are querying any data source, such as a database, even an Access database, then parameterized querying in Excel can truly simplify your workflow. I am going to cover SQL queries specifically, but please comment below if you would like a tutorial on using a parameter with other data sources. Nearly anything is possible!

You can also easily use parameters in Power BI, but the process for creating the parameter itself is slightly different – I will cover that in a future post.  The query construction is the same in most cases though. Please note that this post assumes you are at least moderately familiar with SQL querying and Power Query. Your mileage may vary depending on your situation.

If you found this post because you are encountering a firewall error when incorporating a parameter, skip right on to that section below (click here) for the solution. After much trial and error, I have found a way that works to overcome this issue harnessing the power of query folding. 

The Solution: Passing a Parameter to a SQL Query

In my example, “SParameter” is the name of the parameter I am using, and it represents a store number (retail location identifier). The related field in my SQL table is [Store].

Create the parameter:

  • In any worksheet, add a new table, with a single record and column.  I highly recommend the Header clearly clarifies what the parameter is so there is no confusion in identifying it.
  • Add this table into Power Query by selecting the table, then Data > From Table/Range
  • When the query editor opens, if necessary, change the data type (in my case I need it to be text).  This is important!
  • Right click on the record and select “Drill Down”.  Since you have only a single record, this step will automatically create a parameter.  
  • In the properties, I name this SParameter (you may enter the name of your choice for your parameter).  Note that the name is case sensitive.

This is how the table is situated in my worksheet (1 is the parameter/the value I will change as needed):

This is how it looks in Power Query after all steps above were completed (I named the column from Enter Store: to Store to make it cleaner (this is an optional step):

Open or Add your SQL Server Query in Power Query

Add your query into the Advanced Editor.


let
Source = Sql.Database(“your connection name”, “your database name”, [Query=”

your query goes here

“])


Create the SQL query with your parameter:

Here’s my simple query example to demonstrate how to build the query with the parameter. Please substitute your table name and fields, as well as your parameter name.

With the parameter in the WHERE clause

“Select  * FROM StoreDetail.Store WHERE Store =” &SParameter&”

  • Simply build your unique SQL statement in Power Query following my example above, adding your parameter into the query with quotes and the & (ampersand) sign surrounding the parameter name.
  • Check the results and modify as needed.
  • If your query has no additional clauses or criteria, simply put quotes and one & sign ahead of the parameter, and then one after followed by two double quotes to close the query statement.

 Additional criteria in the WHERE clause

Here is an example where I have additional criteria in mine, filtering on the OpenDate field; after the second quote, add a space and then continue on with the rest of your query.

Select  * FROM Storelist WHERE Store =” & SParameter &” AND OpenDate < GetDate()-365

This is an example of the properly formatted parameter looks in the Advanced Editor in Power Query (I have built out my query further with the Group By clause – this is optional if it doesn’t apply in your case).

If you are running into issues with the query, you may need to add in single quotes surrounding the parameter (inside of the double quotes – “WHERE Store =‘” & SParameter & “‘;”), or possibly # signs surrounding your parameter inside of the double quotes, if your parameter is a date.  You may have to test with and without these depending on your unique scenario.  

If the query is successful, you can proceed with saving it or adding in additional steps in Power Query if you are further filtering or transforming the resulting data you pulled.

BONUS Information – if you are wondering what GetDate() is, this is the MS SQL current system date, so in a way this is technically a dynamic parameter as well.  In my case, the query will only return stores with an open date that is older than 365 days based on today’s date.  You may find this useful for your query as well if you are looking for dynamic dating.

After updating your parameter in the worksheet table, Select Refresh All from the Data menu and your updated query will run and return the results accordingly!

Managing Privacy Levels in Power Query/Excel

VERY IMPORTANT: If you are sharing your workbook with others, you may need to edit the Privacy Levels in order for the queries with parameters to work for them. Read on for these important steps.

In Excel Power Query, there are security measures in place to help prevent data from being shared unintentionally. When combining query sources by using the parameter (a value in your Excel file with a SQL server source), many times this security comes into play.

If other users are having an issue refreshing the query/queries where you have added a parameter into the SQL query, please have them follow these steps. I actually copy and paste this right into an Instructions tab of each of the shared workbooks containing parameters that I create for my clients and for colleagues.

  • Go to Data, click Queries & Connections.
  • Your query list will show up in the panel on the right.
  • Right click any query in the list and choose Edit.
  • A window will open. Click File, then Options and settings.
  • Choose Query Options.
  • Click Privacy, which is on the menu on the left, at the bottom.
  • Select the radio button for the Ignore the Privacy Levels and potentially improve performance option.
  • Click OK to save.
  • Click Close & Load in the Power Query Editor window (at the top) to exit the settings.
Parameter to a SQL query (privacy settings)

Troubleshooting/Alternate Method – Firewall issue

If you run into this dreaded error: “Formula.Firewall: Query ‘SParameter (2)’ (step ‘Filtered Rows’) references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.”, then you will need to use this alternate method.

If you received the firewall error above, you can still use your parameter, but you will instead need to use the parameter as a filter in a subsequent step.  Now you may be possibly thinking – my table has thousands (or even millions) of records and I don’t want them all pulling in – don’t worry, this is the beauty of the query folding process when it works properly in Power Query.

Without the parameter in the WHERE clause

Select * FROM StoreDetail.Store WHERE OpenDate < GetDate()-365

  • Write your SQL statement in Power Query as noted above.
  • When the Query Editor returns the columns and record sampling, for the field you will be using your parameter, filter with any single value (Text Filters > Equals). This is simply a placeholder, to create the Power Query M formula for the next step.
  • You will now see that filtering in the formula bar. 
  • Replace the placeholder value with the name of your parameter, removing any quotes from the placeholder.  This is how it looks for me: = Table.SelectRows(Source, each [Store] = SParameter).
  • Power Query is smart enough to modify its native query to use the parameter, so it’s not going to pull in the millions of records and then filter after the fact.  Success!!  This is the power of Query Folding!

Why Can’t You Include the Parameter in the SQL Statement?

In the SQL statement, in most cases we will want add the store number/SParameter as part of the criteria in the select statement.  It may seem counter intuitive, but we cannot always successfully put the parameter directly into the SQL code/query. The challenge is that you are combining data sources and at this time, this is not allowed due to the built in security (SParameter portion is local, SQL portion is external).  Unfortunately some organizations have policies that disallow this. Sometimes it is an Excel version issue.

I truly hope this post helped you out.  If so, please feel free to leave a comment below letting me know so, and if you’d like, add what you’d like me to cover in a future post. Also, feel free to share this with someone else who may find it useful.

Do You Need Personalized Help and Custom Solutions?

If you get stuck or you would like to explore solutions and automation possibilities, please can reach out to me for help as I do offer consulting services as time allows.  I have over 20+ years’ of expert level experience delivering excellent, custom, strategic solutions in Excel, BI, Access, SharePoint and more. 

I have been called a guru and hero more times than I can count, as I am a great listener and truly have a knack for asking the right questions to understand unique business challenges. I am very passionate about crafting tools and processes that work for users of all levels and experience. 

Reach out today and let’s discuss how I can help you and your business!

I also offer one-on-one tutoring for customized learning and upskilling. Visit my consulting page and send a message if you are interested.

Other Excel Resources

Also, consider checking out some great Excel resources on Amazon Disclosure: this is an affiliate link, so I may earn a small commission if you decide to make a purchase, which will help cover the cost of hosting this website. 

Please bookmark and subscribe!  I am actively working on adding new, relevant content to help others out! Thanks so much!

Subscribe via Email and Stay Up to Date!

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Buy Me A Coffee/Support the Blog 🙂

If I helped you, please consider leaving a tip via PayPal to support the blog! Thanks!!

Thanks so much for supporting my blog and for helping others too!

Cross Selling Matrix Deep Dive – Power BI & DAX Tutorial (Market Basket)

Understanding the Cross Selling Matrix in Power BI

A cross selling matrix is a powerful visualization used in sales analytics to identify which products are often purchased together by the same customers over a selected period. This form of basket analysis helps businesses uncover cross-selling opportunities, promotional ideas, boost revenue, and optimize product strategy.

The video demonstrates not just the process of creating a cross selling matrix in Power BI, but dives deep into the crucial concepts of DAX, context transition, and relationship management needed to generate accurate, actionable insights.

Key Steps and Concepts

1. Foundational Understanding: Context in Power BI & DAX

  • Context determines how your formulas and visuals behave. The row and column headers of your matrix create unique contexts for every cell, impacting which data is aggregated or filtered.
  • Proper understanding of context ensures your DAX calculations are returning meaningful results for each product pairing in the matrix.

2. Core Calculation: Customers Who Purchased Both Products

  • The goal is to find out, for any intersection in the matrix, how many customers bought Product A (row) AND Product B (column) within the selected date range.
  • This is done by creating two tables:
  • Table 1: All customers who bought Product A.
  • Table 2: All customers who bought Product B.
  • The INTERSECT function is then used to find customers common to both tables.
  • The final result is a COUNTROWS(INTERSECT(…)), revealing the number of unique customers who purchased both products.

3. DAX Techniques Used

  • VALUES(): Used to dynamically return a list of customers filtered by the current context (product, time frame, etc.).
  • CALCULATETABLE(): Allows creation of virtual tables filtered by specific product or comparison product context.
  • TREATAS(): Establishes virtual relationships between tables where no direct relationship exists, vital for comparing separate product lists.
  • ALL() or ALLEXCEPT(): Used to remove or adjust existing model relationships temporarily, isolating the proper comparison across products for accurate results.

4. Supporting Table for Comparison

  • To evaluate pairwise cross-selling (row vs column), a comparison products table is created, usually replicating your products dimension but used solely for comparison logic.
  • This table is not physically related to the sales table, so relationships are built on-the-fly in DAX using TREATAS.

5. Dynamic Filtering and Analysis

  • The entire technique is dynamic, meaning selecting different dates or filters in your Power BI report instantly recalculates the matrix.
  • This adaptability makes the matrix valuable for both exploratory analytics and operational dashboards.

Why Build a Cross Selling Matrix?

  • Reveal Product Affinities: Quickly see which items are often bought together, ideal for bundle promotions and recommendations.
  • Drive Sales Strategies: Identify which products could benefit from cross-promotion or upselling.
  • Customer Insight: Understand multi-product purchasing behavior within your customer base.

Example DAX Pattern for Purchased Both Products

Purchased Both Products = 
VAR Customers_ProductA =
    VALUES(Sales[CustomerID]) // For current row product context
VAR Customers_ProductB =
    CALCULATETABLE(
        VALUES(Sales[CustomerID]),
        TREATAS(VALUES('Comparison Products'[ProductID]), Sales[ProductID])
    )
RETURN
    COUNTROWS(INTERSECT(Customers_ProductA, Customers_ProductB))
  • Replace column/table names as per your own model.
  • Adjust context and relationships as necessary for your specific data schema.

Takeaway

By mastering this advanced cross selling matrix technique and the supporting DAX concepts (like context, table functions, and virtual relationships), you empower yourself to unlock powerful, nuanced insights into customer behavior and product performance using Power BI.

If you’re keen to further enhance your skills on this, Enterprise DNA is a superb resource! Check them out and watch their video on this below! 🙂


[1] https://www.youtube.com/watch?v=iZJz30LSik4

Formula.Firewall Error in Power Query & Power BI: Rebuild This Data Combination Solved (MSPTDA 9.5)

Learn how to deal with Power Query Error: Formula.Firewall: Query references other queries or steps, so it may not directly access a data source. Please rebuild this data combination. Two solutions are presented in this video.
Download Files: Excel Start: https://ift.tt/2L7OwpO
Zipped Folder: https://ift.tt/2PShOvY
Download Excel FINISHED Files: https://ift.tt/2MsL7Hs
Download pdf Notes about Power Query: https://ift.tt/2wkNW2K
Assigned Homework – these are problems for you to practice your new M Code skills:
Download Excel File with Homework: https://ift.tt/2MmtxFf
Example of Finished Homework: https://ift.tt/2L7OxtS

Chris Webb’s blog about this topic: https://ift.tt/2NATkG3
Ken Puls blog about this topic: https://ift.tt/2PShRb8

Comprehensive Microsoft Power Tools for Data Analysis Class, BI 348, taught by Mike Girvin, Excel MVP and Highline College Professor.

View on YouTube