0% found this document useful (0 votes)
15 views19 pages

Power BI Tutorial

Power BI is a Microsoft business intelligence tool that enables users to analyze, visualize, and share data through interactive dashboards and reports. It offers various products like Power BI Desktop, Power BI Service, and Power BI Mobile, catering to different user needs from individual analysts to large enterprises. Key features include data connectivity, transformation, modeling, and real-time updates, making it suitable for both cloud-based and on-premises BI solutions.

Uploaded by

snehal.dholi30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views19 pages

Power BI Tutorial

Power BI is a Microsoft business intelligence tool that enables users to analyze, visualize, and share data through interactive dashboards and reports. It offers various products like Power BI Desktop, Power BI Service, and Power BI Mobile, catering to different user needs from individual analysts to large enterprises. Key features include data connectivity, transformation, modeling, and real-time updates, making it suitable for both cloud-based and on-premises BI solutions.

Uploaded by

snehal.dholi30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Power BI is a business intelligence (BI) tool developed by Microsoft that allows users to

analyze, visualize, and share data. It provides interactive dashboards, reports, and data
modeling capabilities to help organizations make data-driven decisions .
🔹 Key Features of Power BI
1. Data Connectivity – Connects to multiple data sources like Excel, SQL Server,
Azure, APIs, etc.
2. Data Transformation – Cleans and processes data using Power Query.
3. Data Modeling – Uses DAX (Data Analysis Expressions) for calculations.
4. Interactive Visualizations – Provides charts, graphs, and KPI dashboards.
5. Power BI Service – Cloud-based platform for sharing reports.
6. Real-time Data Updates – Supports auto-refresh and live connections.
7. AI & Machine Learning – Integrates with AI to uncover insights.

Power BI Products and Offerings 🚀


Power BI provides a suite of products designed for different users, from individual analysts
to large enterprises. These products help in data visualization, analysis, and sharing.

1️⃣ Power BI Desktop


📌 What it is:
 A free Windows application for building reports and dashboards.
 Supports data modeling, DAX calculations, Power Query, and visualizations.
📌 Who uses it?
 Data Analysts, Business Analysts, and Developers who create reports.

2️⃣ Power BI Service (Power BI Online)


📌 What it is:
 A cloud-based platform for sharing, collaborating, and publishing Power BI reports.
 Allows scheduled refresh, security management, and live data connections.
📌 Who uses it?
 Business users, decision-makers, and teams for report access and collaboration.
🔹 Versions:
 Power BI Pro (Paid) → For individual users to share reports.
 Power BI Premium (Paid) → For large enterprises, with better performance and AI
capabilities.

3️⃣ Power BI Mobile


📌 What it is:
 A mobile app for accessing Power BI reports on iOS, Android, and Windows devices.
 Supports interactive reports and push notifications for data alerts.
📌 Who uses it?
 Executives, managers, and field workers who need insights on the go.
4️⃣ Power BI Report Server
📌 What it is:
 An on-premises version of Power BI Service , allowing organizations to host reports locally.
 Supports Power BI reports, paginated reports, and mobile reports.
📌 Who uses it?
 Organizations with strict security and compliance requirements that cannot store data in
the cloud.

5️⃣ Power BI Embedded


📌 What it is:
 A set of APIs and SDKs that allow developers to embed Power BI reports into custom
applications.
 Does not require users to sign into Power BI.
📌 Who uses it?
 Developers and software companies that want to integrate Power BI into their applications.

6️⃣ Power BI Gateway


📌 What it is:
 A tool that allows Power BI Service to connect with on-premises data sources.
 Supports both scheduled refresh and live connections.
📌 Who uses it?
 IT administrators and data engineers managing on-premise data connections.

7️⃣ Power BI Visuals Marketplace


📌 What it is:
 A marketplace for custom visuals that can be added to Power BI reports.
 Includes visuals like charts, maps, KPI indicators, and AI-powered analytics.
📌 Who uses it?
 Data analysts and developers who need advanced or custom visuals.

✅ Summary Table of Power BI Products


Product Purpose Best for

Power BI Desktop Build reports & dashboards Data analysts

Power BI Service Share & collaborate on reports Business users

Power BI Mobile Access reports on mobile devices Executives & field teams

Power BI Report Server Host reports on-premises Enterprises with security needs

Developers & software


Power BI Embedded Embed reports in applications
companies

Connect cloud Power BI with on-


Power BI Gateway IT administrators
premises data
Product Purpose Best for

Power BI Visuals
Add custom visuals to Power BI reports Analysts & developers
Marketplace

1️⃣ Cloud-Based BI (Power BI Service)


📌 What it is:
 BI tools and data are hosted on cloud platforms like Microsoft Azure, AWS, or Google Cloud.
 Users can access reports and dashboards via a web browser from anywhere.
 No need for physical servers or infrastructure management.
📌 Key Features:
✅ Easy Access – Can be used from any device with an internet connection.
✅ Automatic Updates – Always uses the latest features.
✅ Scalability – Can handle large data volumes easily.
✅ Lower Upfront Cost – No need for expensive servers or hardware.
✅ Collaboration – Users can share reports easily with teams.
📌 Example:
🔹 Power BI Service (Power BI Online) – Microsoft’s cloud-based BI solution.
📌 Best for:
 Small to medium businesses.
 Organizations looking for cost-effective, scalable, and easily accessible BI solutions.

2️⃣ On-Premises BI (Power BI Report Server)


📌 What it is:
 BI tools and data are stored within a company’s own data center or servers.
 Requires internal IT infrastructure for storage, management, and maintenance.
 Offers full control over data security and compliance.
📌 Key Features:
✅ Data Security & Compliance – Suitable for industries with strict regulations (e.g.,
healthcare, finance).
✅ Full Control – Companies manage their own servers and data storage.
✅ No Internet Dependency – Works even without internet access.
📌 Example:
🔹 Power BI Report Server – Microsoft's on-premises BI solution for secure data hosting.
📌 Best for:
 Large enterprises with strict security requirements.
 Organizations that cannot store sensitive data in the cloud.

🔍 Cloud-Based BI vs. On-Premises BI: Comparison Table


Feature Cloud-Based BI On-Premises BI

Hosted on cloud (Microsoft Azure, AWS,


Infrastructure Hosted on company’s own servers
etc.)

Accessibility Accessible from anywhere Limited to internal network


Feature Cloud-Based BI On-Premises BI

Scalability Easily scalable Requires hardware upgrades

Cost Subscription-based (low upfront cost) High upfront cost (servers, maintenance)

Maintenance Handled by cloud provider Requires in-house IT team

Data Security Depends on cloud provider Full control over security

More difficult to share outside the


Collaboration Easy to share reports across teams
organization

✅ Which One Should You Choose?


✔ Choose Cloud-Based BI if:
 You need easy access, lower cost, and scalability.
 Your business does not have strict data security regulations.
 You want automatic updates without IT maintenance.
✔ Choose On-Premises BI if:
 Your organization has highly sensitive data that must stay on local servers.
 You need full control over data security and compliance.
 You have an in-house IT team to manage infrastructure.
Power BI Desktop: The Core Tool for Building Reports 🚀
📌 What is Power BI Desktop?
Power BI Desktop is a free Windows application used to connect, transform, and
visualize data. It is the primary tool for creating interactive reports and dashboards
before publishing them to Power BI Service.

🔹 Key Features of Power BI Desktop


1. Data Connectivity – Connects to multiple data sources like Excel, SQL Server, APIs, and cloud
services.
2. Data Transformation (Power Query Editor) – Cleans and prepares data with filtering,
merging, and shaping functions.
3. Data Modeling – Establishes relationships between tables and creates calculated columns,
measures, and hierarchies.
4. DAX (Data Analysis Expressions) – Allows creating custom calculations and aggregations.
5. Visualization Tools – Provides charts, graphs, tables, and KPIs for data representation.
6. Report Creation – Enables designing interactive dashboards with slicers, drill-through, and
bookmarks.
7. Publishing to Power BI Service – Reports can be shared online with teams for collaboration.

🔹 Components of Power BI Desktop


Component Description

Home Ribbon Contains options to import data, transform data, and publish reports.
Component Description

Power Query Editor Used for data cleaning and transformation before loading into the model.

Data View Displays the raw data tables imported into Power BI.

Model View Shows relationships between tables in a diagram format.

Report View The main area for designing visualizations and dashboards.

Fields Pane Lists tables, columns, and measures available for use in reports.

Visualizations Pane Contains charts, tables, and custom visuals to represent data.

Filters Pane Allows applying filters to visuals, pages, or the entire report.

🔹 Steps to Use Power BI Desktop


1️⃣ Download & Install – Install Power BI Desktop from Microsoft’s official site.
2️⃣ Connect to Data – Import data from Excel, SQL, APIs, or cloud sources.
3️⃣ Transform Data – Use Power Query Editor to clean and shape data.
4️⃣ Build Data Model – Define relationships between tables and create measures using
DAX.
5️⃣ Create Visuals – Add charts, slicers, maps, and tables to represent data.
6️⃣ Enhance Reports – Use filters, drill-through, and conditional formatting for better
insights.
7️⃣ Publish to Power BI Service – Share reports with others for collaboration and online
access.

🔹 Advantages of Power BI Desktop


✅ Free to Use – No subscription required.
✅ User-Friendly Interface – Drag-and-drop functionality makes it easy to use.
✅ Multiple Data Source Connectivity – Supports databases, cloud services, and files.
✅ Advanced Analytics – DAX functions for complex calculations.
✅ Interactive Reports – Allows user-driven filtering and interactions.

🔹 Power BI Desktop vs. Power BI Service


Feature Power BI Desktop Power BI Service

Purpose Used for report creation and development Used for sharing and collaboration

Installation Installed on Windows PCs Cloud-based (accessible via browser)

Data Storage Stores data locally Stores data on Microsoft cloud

Data Refresh Manual refresh Supports scheduled refresh

Collaboration Limited (single-user editing) Multi-user collaboration possible


✅ Conclusion
Power BI Desktop is essential for creating professional reports before sharing them on Power
BI Service. It provides powerful data modeling, visualization, and analysis tools for
business intelligence.

📌 Step 1: Download & Install Power BI Desktop


1. Go to Power BI Download Page.
2. Install Power BI Desktop on your system.
3. Open Power BI Desktop after installation.

📌 Step 2: Import Data


We will use an Excel file containing sales data.
1. Download Sample Data 👉 Click Here (You can use any sales dataset).
2. Open Power BI Desktop and click Home → Get Data → Excel.
3. Select the Excel file and click Load to bring the data into Power BI.

📌 Step 3: Clean & Transform Data (Power Query Editor)


1. Click Transform Data to open Power Query Editor.
2. Check for missing values and incorrect data types.
3. Remove unnecessary columns if needed.
4. Click Close & Apply to save changes.

📌 Step 4: Create a Data Model


1. Click on Model View (left sidebar).
2. If using multiple tables, define relationships (e.g., Sales Table → Product Table).
3. Ensure key columns (like Product ID) are linked correctly.

📌 Step 5: Create Visualizations


Now, let’s add some visuals to analyze sales performance.
🔹 1. Total Sales Card
1. Click on Card Visual (from Visualizations pane).
2. Drag Sales Amount into the Values field.
3. It will display the Total Sales in a single value format.
🔹 2. Sales by Region (Bar Chart)
1. Click on Clustered Bar Chart visual.
2. Drag Region into the Axis field.
3. Drag Sales Amount into the Values field.
4. This will show Sales by Region in a bar chart.
🔹 3. Sales Trend Over Time (Line Chart)
1. Click on Line Chart.
2. Drag Order Date into the X-axis field.
3. Drag Sales Amount into the Values field.
4. This will display Sales Trends over Time.
🔹 4. Product-wise Sales (Pie Chart)
1. Click on Pie Chart.
2. Drag Product Name into the Legend field.
3. Drag Sales Amount into the Values field.
4. This will show Sales distribution by product.

📌 Step 6: Apply Filters & Slicers


1. Click on Slicer Visual.
2. Drag Region into the slicer.
3. This allows users to filter data by region interactively.

📌 Step 7: Add a DAX Measure


Let’s calculate Total Sales using DAX.
1. Go to Modeling → New Measure.
Introduction to Power BI
Power BI is a business intelligence (BI) and data visualization tool developed by
Microsoft. It enables users to connect, transform, analyze, and visualize data from various
sources to create interactive reports and dashboards. Power BI provides a self-service
analytics experience, allowing both technical and non-technical users to make data-driven
decisions.
Key Features of Power BI
 Data Connectivity: Supports multiple data sources like Excel, SQL Server, Azure, and cloud-
based services.
 Data Transformation: Uses Power Query for data cleaning and transformation.
 Data Modeling: Uses Power Pivot with DAX (Data Analysis Expressions) for calculations.
 Interactive Dashboards: Provides drag-and-drop functionality to create reports.
 Cloud & On-Premises Support: Available as Power BI Desktop, Power BI Service, and Power
BI Mobile.
 AI & Machine Learning Integration: Supports AI-driven insights, natural language Q&A, and
predictive analytics.

History of Power BI
Early Development (2010-2015)
 2010 – Microsoft introduced Project Crescent, a data visualization tool for SQL Server.
 2011 – Project Crescent was renamed Power View and integrated into SQL Server 2012.
 2013 – Microsoft released Power BI for Office 365, combining Power Query, Power Pivot,
and Power View.
 2015 – Microsoft launched Power BI as a standalone cloud-based service, making it a full-
fledged BI tool.
Growth and Advancements (2016-Present)
 2016 – Power BI became a market leader in BI and analytics, with monthly updates.
 2017 – Integration with Azure, AI, R, Python, and natural language processing.
 2018-2020 – Power BI introduced Paginated Reports, Dataflows, and AI-powered analytics.
 2021-Present – Advanced governance, security, and hybrid BI capabilities were added,
making Power BI a leading enterprise BI tool.
Current Status
Power BI is now one of the most widely used BI tools, competing with Tableau, QlikView,
and Looker. It is part of the Microsoft Power Platform and integrates with tools like
Azure, Excel, SQL Server, and Dynamics 365.

📌 1. Introduction to DAX
✅ What is DAX?
DAX (Data Analysis Expressions) is a formula language used in Power BI, Excel Power
Pivot, and SQL Server Analysis Services (SSAS) to perform calculations on data.
It helps in data modeling by creating new columns, measures, and tables based on existing
data.
✅ Why Use DAX?
DAX allows you to:
 Create calculated columns, measures, and tables.
 Perform complex calculations efficiently.
 Handle relationships between different tables.
 Apply dynamic aggregations and filtering in reports.

📌 2. Key Components of DAX


✅ A. DAX Syntax
DAX formulas follow a specific structure:

New_Column = TableName[Column1] * TableName[Column2]


Sales= Bike_Data[listprice) * Bike_Data[qty]
DAX expressions involve:
1. Functions – Predefined operations (e.g., SUM(), CALCULATE())
2. Operators – Mathematical (+, -, *, /), logical (&&, ||), and comparison (=, >, <)
3. References – Table and column names
4. Filters – Conditions applied to data

✅ B. Types of DAX Calculations


DAX provides three main types of calculations:
1️⃣ Calculated Columns
 Created at the row level in a table.
 Stored in memory.
 Uses row context.
 Example:
DAX
TotalPrice = Sales[Quantity] * Sales[UnitPrice]
 The result is stored in each row of the column.
2️⃣ Measures
 Created dynamically in reports.
 Uses filter context.
 Optimized for performance (calculated only when used in visuals).
 Example:
DAX
TotalSales = SUM(Sales[TotalPrice])
 It is not stored in the table but calculated when used.
3️⃣ Calculated Tables
 Creates a new table in the data model.
 Example:
SalesSummary = SUMMARIZE(Sales, Sales[Category], "Total",
SUM(Sales[TotalPrice]))
 Used for creating custom aggregated tables.

📌 3. Common DAX Functions


DAX functions are categorized into different types:
✅ A. Aggregation Functions
Used to perform mathematical operations on columns.
Function Description Example

SUM() Adds all values in a column SUM(Sales[Revenue])

AVERAGE() Returns the average value AVERAGE(Sales[Revenue])

MIN() Finds the minimum value MIN(Sales[Revenue])

MAX() Finds the maximum value MAX(Sales[Revenue])

COUNT() Counts non-empty values COUNT(Sales[ProductID])

COUNTROWS() Counts total rows in a table COUNTROWS(Sales)

✅ B. Logical Functions
Used for decision-making based on conditions.
Function Description Example

Returns one value if TRUE,


IF() IF(Sales[Quantity] > 10, "Bulk", "Small")
another if FALSE

Checks multiple conditions SWITCH(Product[Category], "A", "High", "B",


SWITCH()
and returns a value "Medium", "C", "Low")

Returns TRUE if both AND(Sales[Revenue] > 1000, Sales[Quantity] >


AND()
conditions are met 5)

Returns TRUE if at least one OR(Sales[Revenue] > 1000, Sales[Quantity] >


OR()
condition is met 5)

✅ C. Text Functions
Used for handling string operations.
Function Description Example
CONCATENATE(Customer[FirstName],
CONCATENATE() Combines two strings
Customer[LastName])

Extracts characters
LEFT() LEFT(Product[Code], 3)
from the left

Extracts characters
RIGHT() RIGHT(Product[Code], 4)
from the right

Returns the length of a


LEN() LEN(Customer[Name])
string

Finds the position of


SEARCH() SEARCH("Bike", Product[Name], 1, -1)
text
✅ D. Date & Time Functions
Used for time-based calculations.
Function Description Example

TODAY() Returns the current date TODAY()

Returns the current date and


NOW() NOW()
time

YEAR() Extracts the year YEAR(Sales[OrderDate])

MONTH() Extracts the month MONTH(Sales[OrderDate])

Calculates the difference DATEDIFF(Sales[StartDate],


DATEDIFF()
between two dates Sales[EndDate], DAY)

✅ E. Filter Functions
Used for data filtering.
Function Description Example

FILTER() Returns a filtered table FILTER(Sales, Sales[Revenue] > 1000)

Ignores filters applied to a


ALL() ALL(Sales[ProductCategory])
column

Keeps user-applied filters but


ALLSELECTED() ALLSELECTED(Sales[Product])
removes internal filters

Preserves existing filters when KEEPFILTERS(FILTER(Sales,


KEEPFILTERS()
applying new ones Sales[Region] = "West"))

📌 4. Advanced DAX Functions


✅ A. CALCULATE() - The Most Powerful DAX Function
CALCULATE() modifies context by applying filters.

SalesWest = CALCULATE(SUM(Sales[TotalPrice]), Sales[Region] = "West")


It changes how a measure is evaluated by modifying the filter context.

✅ B. Context in DAX
1️⃣ Row Context
 Exists inside calculated columns.
 Evaluates expressions row by row.
Example:
DAX
Profit = Sales[Revenue] - Sales[Cost]
2️⃣ Filter Context
 Exists inside measures and visuals.
 It filters data before calculation.
Example:
DAX

TotalSalesWest = CALCULATE(SUM(Sales[Revenue]), Sales[Region] = "West")

📌 5. DAX Best Practices


✔ Use measures instead of calculated columns when possible (better performance).
✔ Minimize the use of nested filters for efficient calculations.
✔ Use CALCULATE() for modifying filter context dynamically.
✔ Optimize DAX queries by reducing unnecessary filters and using summarization
functions.

Function Definition Use Case


SUM() Adds up all values in a column. Used for direct column aggregation.
Iterates row by row, performing Used when calculations need to be
SUMX()
calculations before summing. performed on each row first.
Example:
 SUM:
DAX
Total Sales = SUM(Sales[Amount])
(Direct sum of Amount column)
 SUMX:
DAX
Total Revenue = SUMX(Sales, Sales[Quantity] * Sales[Price])

Row-Level Security (RLS) in Power BI


Row-Level Security (RLS) is a feature in Power BI that restricts data access at the row level
based on user roles. It ensures that users can only see data relevant to them, enhancing
security and privacy.

How Row-Level Security Works


1. Define Roles in Power BI Desktop
o Create roles using DAX filters to restrict data access.
2. Apply DAX Filters to Tables
o Filters limit data visibility based on user attributes like email, region, or
department.
3. Assign Users to Roles in Power BI Service
o Users/groups from Azure Active Directory (AAD) are assigned roles to
enforce security.
Types of Row-Level Security
1. Static RLS – Manually define filters based on fixed values.
o Example: A sales team can only see data for their assigned region.
[Region] = "West"
2. Dynamic RLS – Uses USERPRINCIPALNAME() or USERNAME() to dynamically filter
data based on logged-in users.
o Example: Each employee can see only their own records.
[Email] = USERPRINCIPALNAME()
3. Hierarchical RLS – Allows managers to see data for their subordinates.
o Example: Managers can view their team's data.
DAX
LOOKUPVALUE(Employee[Manager], Employee[Email], USERPRINCIPALNAME())
= Employee[Manager]

Example Use Case


Scenario:
A retail company wants to restrict sales data based on region:
 Sales managers should see only their assigned regions.
 Regional heads should see all data in their region.
Implementation Steps:
1. Create a Role in Power BI Desktop
2. Apply DAX Filter:
DAX
[Region] = LOOKUPVALUE(Employee[Region], Employee[Email],
USERPRINCIPALNAME())
3. Publish and Assign Users in Power BI Service

Benefits of RLS in Power BI


✅ Improves data security by restricting access.
✅ Enhances performance by reducing unnecessary data loads.
✅ Ensures compliance with data governance policies.
Difference Between Calculated Columns and Measures in Power BI
Feature Calculated Column Measure

A formula that calculates values


A column created using DAX that is stored in
Definition dynamically based on user
the dataset.
interactions.

Physically stored in the data model, increasing Not stored; calculated on the fly when
Storage
file size. used in visuals.

Computed at the row level when data is Computed at the aggregation level
Calculation
loaded or refreshed. based on filters in a visual.

Can slow performance due to increased data More efficient as it calculates only
Performance
storage. when needed.

Usage Used when you need a new column in a table, Used for aggregations like sum,
like concatenating names or categorizing data. average, count, and dynamic
Feature Calculated Column Measure

calculations.

Example of a Calculated Column


Scenario: You want to create a "Full Name" column by combining First Name and
Last Name.
DAX
Full Name = 'Employees'[First Name] & " " & 'Employees'[Last Name]
✅ Stored in the table and can be used like any other column.

Example of a Measure
Scenario: You want to calculate the total sales dynamically based on filters.
DAX
Total Sales = SUM(Sales[Amount])
✅ Calculated only when used in a visual, improving performance.

Power BI Measures Examples (Using DAX)


Measures in Power BI are used to perform aggregations, calculations, and dynamic
filtering based on user interactions. Below are common DAX measures with real-world use
cases.

1️⃣ Total Sales Measure (Summation)


Calculates the total sales amount.
DAX
Total Sales = SUM(Sales[Amount])
✅ Used in reports to display the overall revenue.

2️⃣ Average Sales per Order (Averaging)


Finds the average sales per order.
DAX

Avg Sales per Order = AVERAGE(Sales[Amount])


✅ Helps in understanding the revenue per transaction.

3️⃣ Count of Orders (Counting)


Counts the number of orders placed.
DAX
Total Orders = COUNT(Sales[Order ID])
✅ Useful for tracking sales volume over time.
4️⃣ Distinct Customer Count
Counts the number of unique customers who made a purchase.
Unique Customers = DISTINCTCOUNT(Sales[Customer ID])
✅ Helps in analyzing customer engagement.

5️⃣ Year-over-Year (YoY) Sales Growth


Compares sales from the previous year to the current year.
DAX
YoY Growth =
VAR LastYearSales = CALCULATE(SUM(Sales[Amount]),
SAMEPERIODLASTYEAR(Sales[Date]))
RETURN
DIVIDE(SUM(Sales[Amount]) - LastYearSales, LastYearSales, 0)
✅ Useful for financial analysis and trend monitoring.

6️⃣ Running Total (Cumulative Sales)


Calculates cumulative sales over time.
DAX
Cumulative Sales =
CALCULATE(
SUM(Sales[Amount]),
FILTER(ALLSELECTED(Sales), Sales[Date] <= MAX(Sales[Date]))
)
✅ Used in trend analysis and forecasting.

7️⃣ Percentage of Total Sales


Finds each product’s contribution to total sales.
DAX

% of Total Sales =
DIVIDE(SUM(Sales[Amount]), CALCULATE(SUM(Sales[Amount]), ALL(Sales)), 0)
✅ Helps in analyzing product performance.

8️⃣ Dynamic Ranking of Products


Ranks products based on total sales.
DAX

Product Rank = RANKX(ALL(Sales[Product Name]), SUM(Sales[Amount]), , DESC,


DENSE)
✅ Used for identifying best-selling products.

9️⃣ Sales for Selected Date Range


Calculates total sales based on a selected date range in a report.
DAX
Selected Period Sales =
CALCULATE(SUM(Sales[Amount]), DATESBETWEEN(Sales[Date],
STARTOFMONTH(TODAY()), TODAY()))
✅ Filters sales dynamically based on the date slicer.

🔹 When to Use Measures?


 When you need aggregations (SUM, COUNT, AVG, MAX, MIN).
 When you want dynamic calculations based on slicers/filters.
 When optimizing model performance (measures do not consume extra storage).
Power BI Calculated Columns Examples (Using DAX)
A calculated column is a new column added to a table using DAX. It is stored in the dataset
and calculated for each row when data is loaded or refreshed.

1️⃣ Full Name Column (Concatenation)


Combines first and last names into a single column.
DAX

Full Name = Employees[First Name] & " " & Employees[Last Name]
✅ Used for creating a full name field in reports.

2️⃣ Profit Calculation (Mathematical Operations)


Computes profit as the difference between sales and cost.
DAX
Profit = Sales[Total Revenue] - Sales[Total Cost]
✅ Helps in understanding business profitability.

3️⃣ Order Category Based on Sales Amount (Conditional Logic with IF)
Classifies orders based on sales value.
DAX
Order Category =
IF(Sales[Amount] > 1000, "High Value", "Regular")
✅ Used for customer segmentation.

4️⃣ Sales Performance Category (Multiple Conditions with SWITCH)


Categorizes sales based on performance.
DAX
Sales Performance =
SWITCH(
TRUE(),
Sales[Amount] >= 5000, "Excellent",
Sales[Amount] >= 3000, "Good",
Sales[Amount] >= 1000, "Average",
"Low"
)
✅ Helps in performance analysis.
5️⃣ Month Name from Date Column (Extracting Date Parts)
Extracts the month name from a date.
DAX
Month Name = FORMAT(Sales[Order Date], "MMMM")
✅ Useful for time-based reporting.

6️⃣ Year from Date Column


Extracts the year from a date column.
DAX
Year = YEAR(Sales[Order Date])
✅ Used in time-series analysis.

7️⃣ Customer Age Calculation (Date Difference)


Calculates age from birthdate.
DAX
Customer Age = DATEDIFF(Customers[Birth Date], TODAY(), YEAR)
✅ Useful for demographic analysis.

8️⃣ Discounted Price Calculation


Applies a discount percentage to the sales price.
DAX
Discounted Price = Sales[Price] * (1 - Sales[Discount %] / 100)
✅ Used for pricing analysis.

9️⃣ Region Mapping Based on State


Assigns a region to each state.
DAX
Region =
SWITCH(
TRUE(),
Sales[State] IN {"Maharashtra", "Gujarat", "Goa"}, "West",
Sales[State] IN {"Delhi", "Haryana", "Punjab"}, "North",
Sales[State] IN {"Tamil Nadu", "Kerala", "Karnataka"}, "South",
"Other"
)
✅ Helps in regional reporting.

🔹 When to Use Calculated Columns?


 When you need static data stored in the table.
 When creating a new column for relationships or slicers.
 When performing row-wise calculations (not aggregations).

You might also like