Top 10 Power BI Formulas
Top 10 Power BI Formulas
Formula:
=SUMX(<table>, <expression>)
Example:
Here, for each row in the Sales table, it
multiplies Sales[Quantity] by Sales[Profit per
Unit] and then sums up those results.
= SUMX(Sales, Sales[Quantity] *
Sales[Profit per Unit])
AVERAGE
AVERAGE calculates the arithmetic mean
of all the numbers in a specified column.
It's useful for determining the central
value of a set of numbers.
Formula:
=AVERAGE(<column>)
=AVERAGE(Sales[Net Sales])
Example: Here, This calculates the
average of all values in the Sales[Net
Sales] column..
IF
IF checks a condition and returns one
value if the condition is TRUE and
another value if the condition is FALSE.
It's used for conditional logic.
Formula:
=IF(<logical_test>, <value_if_true>,
<value_if_false>)
Example:
This checks if Sales[Net Sales] is greater than
10,000. If true, it returns "Yes"; otherwise, it
returns "No".
= IF(Sales[Net Sales] > 10000, "Yes", "No")
FILTER
FILTER returns a table that represents a
subset of another table or expression,
based on a specified condition. It’s used to
create more specific views of data.
Formula: =FILTER(<table>, <filter>)
Example: It returns a table of sales data
where the Region column equals "North".
= FILTER(Sales, Sales[Region] = "North")
ALL
ALL removes all filters from a specified
table or column. It’s often used in
combination with other functions to
provide a baseline or total value that
isn’t affected by the current filters.
Formula:
=ALL(<table_or_column>))
Example:
This calculates the total net sales without
considering any existing filters on the Sales
table.
= CALCULATE(SUM(Sales[Net Sales]),
ALL(Sales))
ALLEXCEPT
ALLEXCEPT removes all context filters in
a table except filters that have been
applied to specified columns. This allows
for selective removal of filters.
Formula: =ALLEXCEPT(<table>,
<column1>, <column2>, ...)
Example: This keeps all filters on the
Sales[Product Category] column but
removes other filters, and then calculates
the total net sales.
= CALCULATE(SUM(Sales[Net Sales]),
ALLEXCEPT(Sales, Sales[Product
Category]))
RELATED
RELATED returns a related value from
another table. It’s used to bring in data
from a related table in a data model.
Formula:
=RELATED(<column>)
Example:
Assuming there is a relationship between the
= RELATED(Product[Product Name])
Sales and Product tables, this returns the
product name for each sale.
DISTINCT
DISTINCT returns a one-column table that
contains the unique values from the
specified column. It’s useful for identifying
or counting distinct items in a column.
Formula: =DISTINCT(<column>)
Example: This returns a table of unique values
from the Sales[Product Category] column.
= DISTINCT(Sales[Product Category])
@PREMMANDAL
BUSINESS & DATA ANALYST