Power BI Notes
Power BI Notes
Sreerag A
AGENDA
Sreerag A
6) Table Manipulation functions
➢ DISTINCT (column)
Syntax: DISTINCT(<column>)
E.g.: =
COUNTROWS(DISTINCT(InternetSales_USD[CustomerKey]))
➢ SELECTCOLUMNS
Returns a table with selected columns from the table and new
columns specified by the DAX expressions.
Sreerag A
E.g.: = SELECTCOLUMNS(Customer, "Country, State",
[Country]&", "&[State])
➢ SUMMARIZE
E.g.:=SUMMARIZE(ResellerSales_USD
, DateTime[CalendarYear]
, ProductCategory[ProductCategoryName]
➢ TOPN
Sreerag A
E.g.: = SUMX(
TOPN(
10,
SUMMARIZE(
InternetSales,
InternetSales[ProductKey],
"TotalSales", SUM(InternetSales[SalesAmount])
),
[TotalSales], DESC
),
[TotalSales]
Sreerag A
7) Text functions
➢ CONCATENATE
E.g.: CONCATENATE(Customer[LastName],
CONCATENATE(", ", Customer[FirstName]))
➢ FIND
Sreerag A
E.g.: EVALUATE
CALCULATETABLE (
ADDCOLUMNS (
),
➢ SEARCH
Sreerag A
E.g.: EVALUATE
CALCULATETABLE (
ADDCOLUMNS (
),
➢ FORMAT
Sreerag A
E.g.: = FORMAT( 12345.67, "General Number")
➢ LEFT
E.g.: =
CONCATENATE(LEFT('Reseller'[ResellerName],LEFT(Geogra
phyKey,3))
Sreerag A
• If the num_chars argument is a number that is larger than
the number of characters available, the function returns
the maximum characters available and does not raise an
error.
➢ MID
E.g.: MID("abcde",2,3))
➢ REPLACE
➢ SUBSTITUTE
Sreerag A
E.g.: = SUBSTITUTE([Product Code], "NW", "PA")
Sreerag A
8) Time Intelligence functions
Syntax: DATEADD(<dates>,<number_of_intervals>,<interval>)
E.g.: = DATEADD(DateTime[DateKey],-1,year)
➢ DATESBETWEEN
CALCULATE(
DISTINCTCOUNT(Sales[CustomerKey]),
DATESBETWEEN(
'Date'[Date],
BLANK(),
MAX('Date'[Date])
➢ DATESINPERIOD
Sreerag A
E.g.: Revenue PY =
CALCULATE(
SUM(Sales[Sales Amount]),
DATESINPERIOD(
'Date'[Date],
MAX('Date'[Date]),
-1,
YEAR
))
➢ SAMEPERIODLASTYEAR
Syntax: SAMEPERIODLASTYEAR(<dates>)
E.g.: =
CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]),
SAMEPERIODLASTYEAR(DateTime[DateKey]))
There are other time intelligence functions such as
DATESYTD, ENDOFYEAR, TOTALYTD, etc. To know more
about them refer to the following link. Time intelligence
functions (DAX) - DAX | Microsoft Learn
Sreerag A
9) New DAX functions
Sreerag A
Thank you!
Sreerag A