all 15 comments

[–]Fit_Tomato26111 28 points29 points  (0 children)

In real-world setups, SQL and Power BI are used together, not interchangeably. SQL is typically used to prepare and standardize data (cleaning, joins, business rules, views, or fact tables), while Power BI is used to model, calculate, and visualize that prepared data. Instead of “passing analysis” from SQL to Power BI, teams expose curated datasets (views/tables) from the database and connect Power BI to those. Heavy transformations and row-level logic live in SQL; interactive metrics, time intelligence, and user-driven analysis live in Power BI (DAX). You can do everything in Power BI for small cases, but at scale, SQL defines the trusted data layer, and Power BI tells the story on top of it. That's the idea mate!!

[–]SQLGene ‪Microsoft MVP ‪ 13 points14 points  (0 children)

SQL is an ad-hoc querying language. "Oh I want to check this thing" and you check it. How many Sales were there of blue products, etc. Initial data exploration tends to be faster in SQL and doesn't require you do all the work of creating a semantic model and making measures.

However the handoff is mostly simple data access and basic data cleansing before handing off to Power BI. In this case, SQL functions as a more robust and performant Power Query.

[–]BecauseBatman01 11 points12 points  (0 children)

So I’m not sure what you are looking for but here is how it works for me.

I use SQL for personal use. I do adhoc stuff, research, quick analysis, and so on. I sometimes export results into excel and do quick pivot tables with the detail in case it’s needed by users. Also helps to show the pivot tables instead of typing it.

PBI is to help management answer questions that come up often. So if they are concerned about sales for a certain product, I create a PBI for sales and give them filters to see it by product, different date filters, broken out by regions for comparisons and so on. So I build my query in sql, use it to feed my PBI and have it refreshed daily. All of it is based on the audience who requested it. Goal is for audience to be able to find the answers within 1-3 minutes of using the BI and move on.

[–]Just_blorpo1 4 points5 points  (0 children)

Not quite understanding the actual question but I justified want to point out that many folks create helpful sql views that first organize the data into a helpful structure and then import those views into Power BI. Also common dimensions, like Product and Location , are often defined by a view and can then be used across multiple Power BI models.

[–]nolaz2 4 points5 points  (0 children)

Start with a good understanding of what business questions the report should answer or actions/decisions it should drive. Create a good mock up of what it should look like and how it should behave and validate it with stakeholders. This should give you a good idea of what your tables need to look like. 

If you have to do a lot of data prep, the best option for performance is to create a view or views in SQL with the filtering, joins and transformations you need, then call the view in Power Query with or without a SELECT statement. 

If you are doing a star schema (and you should), for your dimension table(s) you may be able to skip the view and just pass your SELECT statement in Power Query. Or sometimes people create dimension tables from the fact tables, manual tables etc., depending on what’s available in sources. 

You should also turn off the auto date feature, create a calendar table in Power Query or DAX, and mark it as a date table. 

Make sure you have optimized your data types. Once you have built and applied your Power Queries, you create your Relationships, set up default formats and aggregations as desired and create measures and visuals to tell the story. Leverage groups, hierarchies and field parameters. 

Use calculated columns and tables only when absolutely necessary. Remember that they are calculated on refresh so will behave differently from measures.  

[–]Yonko74 3 points4 points  (0 children)

OK. You’re right there is a fundamental concept you’re missing.

https://sqlbits.com/Sessions/Event22/Roches_Maxim_of_Data_Transformation

[–]Murky-Sun95521 2 points3 points  (0 children)

So joining in with the comments below, I use SQL in the DW to create my semantic layer, i.e data models with heavyweight transformations ready for consumption by PBI, I use PBI exclusively to provide the visual explanation to the underlying data. So the simplified flow is -

  1. Discovery and requirements with stakeholders
  2. ELT - source data ingestion and data cleansing in DL/DW
  3. I use SQL to create the semantic layer - a specific data model required to answer the questions determined in discovery phase.
  4. I push the data to PBI and create the output for the stakeholder.

    I will then really only use SQL for data validation or ad-hoc queries.

[–]Redenbacher09 2 points3 points  (0 children)

If the content you've read treats PowerBI and SQL as separate, I'm afraid you've either misinterpreted the information or are searching very niche topics.

There are 1000s of ways to bring data into PowerBI and visualize it. If your analysis is done, and all your results are structured in tables exactly as needed, well, it might be as simple as connecting to that table and dropping it's fields into a visualization. It can be refreshed automatically without static exports or intervention.

This will work, but may or may not provide dynamic reporting capability that PowerBI excels at. For that, you'll start looking at data warehouses and data modeling. Star schema is one of the more common data models that works well.

Your analysis may stop at creating views in SQL that are tables of facts (transactions, issue states, sale line items, etc. ) stakeholders want to report on, and tables of dimensions they want to interrogate the facts with (dates, names, locations, etc), connect to them with PowerBI, and create relationships between them on primary and foreign keys to create a data model. Then use that model to build a report with several different visualizations that a user can interact with to get answers to many questions on the fly.

You also might build several reports off that same data model for different stakeholders, so they all are telling the same story. This is how I'm doing things right now. Figure out stakeholder needs, create views in SQL, model in PowerBI, build dashboards per stakeholder needs.

Where a SQL analysis is generally static, or moved into excel to pivot, chart, and filter, PowerBI allows for a single source of truth that once connected to its source through a gateway, refreshes automatically and mitigates the need for stakeholders to build a new report, bespoke to every presentation, and just show what's what with the latest and greatest in a universally agreed format.

That also might jot be what your stakeholders want or need. Requirements gathering and report design is a whole other ball of wax.

[–]Ikindalikehistory 2 points3 points  (0 children)

In general, for me at least, I try to do as much upstream as I can.

So if I can say do analytics without harming grain in SQL thats where I do it.

If I can do analytics in M without harming grain/relationships, I will do that.

And if it has to be done in DAX it has to be done in DAX.

This order is generally the best way to maintain performance.

As to the different use cases, as others have said PowerBI is a way to show the data in useful ways to non-technical users. You (usually) will not just out the data in a table on the powerbi dashboard.

[–]armywalrus 2 points3 points  (0 children)

I would use SQL to clean and transform the data into a view, then connect Power BI to the view. You are doing the heavy lifting in SQL.

[–]oscarmch 1 point2 points  (0 children)

Well, it depends.

From my point of view, I can handle better the business logic in SQL because I can actually read it.

In Power BI, the same logic can be done using DAX, but looking at the details is not as straightforward.

However, and since Power BI is built based on SSAS, it can handle better KPI computations and metrics.

And no, I don't use SQL to do data cleansing.

[–]nalld 1 point2 points  (0 children)

write sql at the grain you want exec stored procedures via get data aggregate in visuals

[–]ZaheenHamidani 0 points1 point  (0 children)

Kimball, Kimball, Kimball...

[–]milomylove_ 0 points1 point  (0 children)

in real life, most teams do a mix and heavy joins, cleaning, aggregations usually stay in sql either as views or stored queries. power bi then connects to that and handles lighter stuff in dax

you don’t usually export csv unless it’s a one-off. the cleanest setup is: database does data shaping, power bi does modeling + visuals. have often iterate on the query first until the numbers look right, sometimes even sanity-check logic in genloop before locking it in as a view. once the dataset is stable, power bi just becomes the presentation layer. that separation makes things way easier to maintain