SQL equivalent

To help understand filter context and to validate certain reports or DAX measures, it can be helpful to compare Power BI reports to SQL statements. The following SQL statement returns the same six values of the Power BI matrix (excluding the subtotals) via standard inner joins and WHERE clause conditions: 

SELECT
P.[Product Category]
, C.[Customer Marital Status]
, FORMAT(SUM(F.[Unit Price] * F.[Order Quantity]), '$#,###') AS [Internet Gross Sales]
FROM BI.vFact_InternetSales as F
INNER JOIN BI.vDim_FinDate as D on F.[Order Date Key] = D.[Date Key]
INNER JOIN BI.vDim_Promotion as Promo on F.[Promotion Key] = Promo.[Promotion Key]
INNER JOIN BI.vDim_Product as P on F.[Product Key] = P.[Product Key]
INNER JOIN BI.vDim_Customer as C on F.[Customer Key] = C.[Customer Key]
INNER JOIN BI.vDim_SalesTerritory as S on F.[Sales Territory Key] = S.[Sales Territory Key]
WHERE D.[Calendar Year Status] in ('Prior Calendar Year', 'Current Calendar Year')
and S.[Sales Territory Group] = 'Europe' and
Promo.[Promotion Type] in ('Excess Inventory', 'Volume Discount')
GROUP BY
P.[Product Category], C.[Customer Marital Status]

In this example, the SQL statement's WHERE clause implements the Power BI report's slicer visual filter and its report and page level filters. The GROUP BY clause accounts for the row and column filters of the matrix visual.

Although certain SQL concepts and examples are applicable, DAX is distinct from SQL and other languages, such as MDX. Additionally, since Power BI import mode datasets are stored in a columnar format, SQL developers experienced with row-based tables and B-tree indexes have to revise their design patterns in developing DAX measures and queries.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.179.220