Professional Documents
Culture Documents
POWERBI
POWERBI
Use of sumx
CALCULATE(SUMX(TABLE_NAME,EXPRESSION)
example
Measure = CALCULATE(DISTINCTCOUNT(Orders[Order
ID]),FILTER(Orders,Orders[Region]="central"))
Measure 3 = CALCULATE(SUM(Orders[Sales]),Orders,Orders[Sub-Category]="machines")
top_N_sales = calculatetable(Orders,TOPN(10,Orders,Orders[Sales]))
Use ASC for bottom and DESC for top profit or sales
AVG DELIVERY =
DATEDIFF(Sheet1[Order Date].[Date],Sheet1[Ship Date].[Date],DAY)
This formula is used to get average delivery date between two dates one is order date and other is ship date.
sales(switch) =
SWITCH(TRUE(),
Orders[Sales]<=100,"bad",
Orders[Sales]<=500,"good","great")
IsBlankFlag =
IF(ISBLANK(YourTable[Column]), "Blank", "Not Blank")
This is use to get a increment in the month or to sift to ther next month
Column = DATEADD(Orders[Order Date].[Date],31,DAY)
Example 6 jan 2023 change to 6 feb 2023
3:
SALES =MRP-DISCOUNT
MRP =200
DISCOUNT=20%
Sales =200-40=60
sales=mrp-mrp*discount
=mrp(1-discount)
mrp=sales/(1-discount)
4:
Sumx (x denotes row by row calculation)
5.
wt.av. profit% =
SUMX(Orders,Orders[Sales]*Orders[profit%]/sum(Orders[Sales]))
Where profit% is sum(profit) /sum(sales)
7:
date of month =
date(Orders[Order Date].[Date])
Same way we can find the month year as well
quarter of year =
QUARTER(Orders[Order Date].[Date])
8: This is used to get the days after which order was delivered (days to ship )
days to ship
= DATEDIFF(Orders[Order Date].[Date],Orders[Ship Date].[Date],day)
customer_name =
SUMMARIZE(Orders,Orders[Customer Name],"sales total",SUM(Orders[Sales]),
"first order", MIN(Orders[Order Date]),
"last order",MAX(Orders[Order Date]),
"customers life",DATEDIFF(MIN(Orders[Order
Date].[Date]),MAX(Orders[Order Date].[Date]),DAY),
"AVG.Customer sales/day",SUM(Orders[Sales])/DATEDIFF(MIN(Orders[Order Date].
[Date]),MAX(Orders[Order Date].[Date]),DAY)
)
FILTERS
10…This expression is used to get the top 20 form the summarized sales or new table
produc_wise_sales = TOPN(20,
SUMMARIZE(Orders,Orders[Product Name],"total
sales",SUM(Orders[Sales])),[total sales],DESC)
or
produc_wise_sales = TOPN(20,
SUMMARIZE(Orders,Orders[Product Name],
"Total quantity",SUM(Orders[Quantity]),
"total sales",SUM(Orders[Sales]),
"avg sales/quantity",SUM(Orders[Sales])/SUM(Orders[Quantity])
),[total sales],DESC)
11.
produc_wise_sales by year =
ADDCOLUMNS(
SUMMARIZE(Orders,Orders[Product Name],Orders[year or order],
"Total quantity",SUM(Orders[Quantity]),
"total sales",SUM(Orders[Sales]),
"avg sales/quantity",SUM(Orders[Sales])/SUM(Orders[Quantity])
),
"rank of sales",
RANKX(SUMMARIZE(Orders,Orders[Product Name],Orders[year or order],
"Total quantity",SUM(Orders[Quantity]),
"total sales",SUM(Orders[Sales]),
"avg sales/quantity",SUM(Orders[Sales])/SUM(Orders[Quantity])
),[total sales],,DESC
))
This expression is used to ger the ranking of the table, below table does the
same but to reduce the line of code we haveused VAR to create the table and
use it for the other expression
produc_wise_sales by year =
var sales_table=
SUMMARIZE(
ADDCOLUMNS(sales_table,
"rank of the table",
RANKX(sales_table,[total sales],,DESC
Return is used to say that VAR operation is over and give the return of the table
12. This is used to find sales with rank
Top 20 sales are produced with this expression.
In this we have used filter , instead of filter
one can use TOP N
sales with rank =
FILTER(
SUMMARIZE(
Orders,Orders[Product Name],Orders[year or order],
"total sales",SUM(Orders[Sales]),
"total quantity",SUM(Orders[Quantity]),
"avg.
sales/order",SUM(Orders[Sales])/SUM(Orders[Quantity])),
RANKX(
SUMMARIZE(
Orders,Orders[Product Name],Orders[year or order],
"total sales",SUM(Orders[Sales]),
"total quantity",SUM(Orders[Quantity]),
"avg.
sales/order",SUM(Orders[Sales])/SUM(Orders[Quantity])),
[total sales],,DESC
)<=20
)
12.
This is same as above changes are lines of codes are shorten
and sales with ranks till 20 are presented with one column
added
12.
If you want to get top 20 sales ranking of each year , so there will be 80 rows
Comparative Analysis Dashboard
First we have created new table and created new column
DATE_DIMENTION = CALENDARAUTO()
year = DATE_DIMENTION[Date].[Year]
Yoy growth
yoy sales growth = DIVIDE([CY SALES]-[py_sales],[py_sales],BLANK())
Budget variances are the differences between the actual and planned amounts of
income and expenses for a given period.
BUDGETED VARIANCE%
BUDGETED VARIANCE% = DIVIDE([CY SALES]-Budget[budgeted
sales],Budget[budgeted sales],BLANK())
Revision and practice(batch 3084)
Class 4
wtd_avg_discount1 =divide
SUMX(Orders,Orders[Discount]*Orders[mrp]),SUM(Orders[mrp]))
If you want to extract data for 1 year form the main source data and create
another table
2014 table =
FILTER(Orders,YEAR(Orders[Order Date].[Date])=2014)
Datediff is used to find the average days taken to deliver the product
AVG_DELIVERY_DATE = DATEDIFF('2014 table'[Order Date].[Date],'2014 table'[Ship Date].
[Date],DAY)
2 from the below expression we can get YTD sales ,so only sales from
the starting to till today
ytd sales =
CALCULATE(TOTALYTD(SUM(Table1[sales]),date_table[Date]),date_table[Date]
<=TODAY())
3.create montly trend chart for sale the sequence of thr months in the
chart should be as per united states financial year?
month_number =
MONTH(date_table[Date].[Date])
Then we have to get range for financial year of US which start from
sep and end october
month range=
IF(date_table[month_number]>9,date_table[month_number]-
9,date_table[month_number]+3
This will be th desired out put
Create a bar chart using subcategory and sum of sales. Add green colour to the
subcategory bars if sum of sales are greater than 150000 ands red colour if sum of sales
are less than 150000?
colur indicator = IF(SUM(Table1[Sales])>150000,"red","green")
Theoretical
What is powerBI?
It is a visualisation or business analytical tool developed by Microsoft which
converts unrelarted data into valuable and interactive insights.
Power Query helps to discover, connect, combine, and refine data sources to
2. Power Pivot
relationship calculations.
3. Power View
Power view helps to create interactive charts, graphs, maps, and other visuals in
Excel, SharePoint, SQL Server, and Power BI that bring data to life.
4. Power Map
5. Power BI Desktop
Power BI desktop helps to get everything easily under the same solution to
6. Power Q&A
Power Q&A is used to explore data in the fastest way to get an answer using
natural language. For example, an answer to a question like what was the total
Pro licence
● Power BI Pro is an individual per-user license that lets users create content and
also read, and interact with content that others have published to the Power BI
service.
● Users with this license type can share content and collaborate with other Power
BI Pro users.
● Can do all
What is DAX ?
DAX is a data analytics expression ,its a collection of functions,operators,used in
formula to calculate and return value to create measures and new tables, by
using these we can dig more insightful data.
Direct Query
The Direct Query connection type is only available when you connect to specific data
sources. In this connectivity type, Power BI will only store the metadata of the
underlying data and not the actual data.
Live Connection
With this connectivity type, it does not store data in the Power BI model. All interaction
with a report using a Live Connection will directly query the existing Analysis Services
model. There are only 3 data sources that support the live connection method - SQL
Server Analysis Services (Tabular models and Multidimensional Cubes), Azure Analysis
Services (Tabular Models), and Power BI Datasets hosted in the Power BI Service.