HW1 ‐ Power BI Guide for Beginners - yentingw-gin/BIDD330_Spring2025_Reporting GitHub Wiki
Overview
This guide is designed for individuals new to Power BI, especially those building a dashboard for the first time. We'll walk through the essential steps to create a Power BI report from scratch using data imported from SQL Server. The article covers the following topics:
- Get the data: How to connect to a SQL Server database and import tables into Power BI
- Build the data model: Step-by-step guidance and best practices for creating a solid data model
- Create and organize measures: Introduction to DAX and organizing your key calculations
- Work with visuals: How to design interactive and insightful visualizations
- Publish the report: How to share your finished dashboard with others using Power BI Service
Get The Data
- Open Power BI Desktop and click on Home > SQL Server
- In the SQL Server database window:
- Enter the server name (e.g., servername.database.windows.net)
- Enter the database name (optional)
- Select Import or DirectQuery as your connection method
- Use Import for faster performance and offline capabilities
- Use DirectQuery to query data live (slower, but always up to date)
- Click OK
- Choose the tables you need
- Click Load
- Use Transform Data if you need to clean or filter data before loading
Build The Data Model
- Go to Model View, then click Manage relationships
- Click New relationship in the Manage relationships window
- In the New relationship window:
- Configure the table relationship
- Repeat this step to add additional relationships as needed
- Once you're done, click Close
- When you've finished designing the model, click Save in the Manage relationships window
- Review the Entity Relationship (ER) Diagram automatically generated in Power BI.
Create And Organize Measures
- Watch this video on how to organize measures with a table for easy access
- Select the mesure table created in Step 1, then click New Measure
- Enter the DAX code to create your measure:
- Repear for other KPIs as needed
- Use DAX variables (VAR) to simplify complex formulas.
See the following DAX code for reference:
Dim Date Total Count Of Month =
VAR _start = STARTOFYEAR( FactCovid[Updated]) -1
VAR _end = ENDOFMONTH( FactCovid[Updated])
VAR MonthCount = DATEDIFF( _start, _end, MONTH ) + 1
RETURN IF (MonthCount = BLANK(),0,MonthCount)
Dim Date Total Row Count =
VAR dimdaterow = COUNTROWS(DimDate)
RETURN dimdaterow
Dim State States Count =
VAR statecount = CALCULATE(COUNT(DimState[State]))
RETURN statecount
Fact Covid Country Distinct Count =
VAR countCountry = CALCULATE(DISTINCTCOUNT(FactCovid[Country_Region]))
RETURN IF(countCountry = BLANK(),0,countCountry)
Fact Unemployment Total Row Count =
VAR unemploymentcount =
COUNTROWS (
FILTER (
FactCovid, --when there is a match from this table
CONTAINS ( FactUnemployment, [State], FactCovid[Admin_Region_1] ) --otherwizard return 0
)
)
RETURN
IF(unemploymentcount = BLANK(),0,unemploymentcount)
Total Row Count of Entrie Dashboard =
VAR totalrowcount = CALCULATE(
[Fact Covid Total Row Count]
+[Fact Unemployment Total Row Count]
+[Dim Date Total Row Count]
+[Dim State Total Row Count]
+[Dim Country Total Row Count]
)
RETURN totalrowcount
Work With Visuals
- Go to Report View
- Choose a visual from the Visualizations pane (e.g., bar chart, pie chart, table)
- Drag fields and measures into Axis, Values, or Legend areas
- Customize the appearance of the visual using the Format Visual pane
Publish The Report
- Save your .pbix file
- Click Home > Publish
- Sign in with your Power BI account.
- Select a workspace in Power BI Service.
Final Notes
- Practice makes perfect. Experiment with DAX, visuals, and filters.
- Use Power BI Community and Microsoft Learn for troubleshooting and tutorials.
- As your skills grow, explore Power Query, custom visuals, and Row-Level Security (RLS).