0% found this document useful (0 votes)
6 views

PowerBI Tutorials

The document provides guidance on creating a rolling calendar in Power BI using DAX and M code, including methods for date calculations and conditional statements. It outlines various DAX functions for data manipulation, such as COUNT, AVERAGE, and SWITCH, along with examples for practical application. Additionally, it covers text functions and performance calculations for year-to-date, quarter-to-date, and month-to-date metrics.

Uploaded by

enid38
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

PowerBI Tutorials

The document provides guidance on creating a rolling calendar in Power BI using DAX and M code, including methods for date calculations and conditional statements. It outlines various DAX functions for data manipulation, such as COUNT, AVERAGE, and SWITCH, along with examples for practical application. Additionally, it covers text functions and performance calculations for year-to-date, quarter-to-date, and month-to-date metrics.

Uploaded by

enid38
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Power BI

Rolling Calendar
a. add Blank Query
b. input starting date
c. convert to table
d. input code

= List.Dates(
Source,
Number.From(DateTime.LocalNow()) -
Number.From(Source),
#duration(1,0,0,0)
)

DAX If statement
Quantity Type =
IF(
'Sales Data'[OrderQuantity]>1,
"Multiple Items",
"Single Item"
)

Blank Table (don’t use unless needed)


Measure Table (DAX) = {" "}

Switch with exact equivalents. EQUALS


Month Number (DAX) =
SWITCH(
'Calendar Lookup'[Month Name],
"January","1",
"February","2",
"March","3",
"April","4",
"May","5",
"June","6",
"July","7",
"August","8",
"September","9",
"October","10",
"November","11",
"December","12",
"Other"
)
Switch and true. with other conditionals. ><=
Price Point =
SWITCH(
TRUE(),
'Product Lookup'[ProductPrice] > 500, "High",
'Product Lookup'[ProductPrice] > 100, "Mid-Range",
"Low"
)
+
-
*
/
^
=
>
<
>=
<=
<>
&
&&
||
IN

LEN(Text)
CONCATENATE (Text1, Text2)
UPPER(Text)
LOWER(Text)
LEFT(Text,[NumChars])
RIGHT(Text,[NumChars])
MID(Text,[StartPosition],[NumChars])
Substitute(Text, OldText, NewText, [instance_num])

search(FindText,WithinText,[StartPosition],[NotFoundValue])

TODAY()
NOW()
DAY(date)
MONTH(date)
YEAR(date)
HOUR(datetime)
MINUTE(datetime)
SECOND(datetime)
WEEKDAY(date, [ReturnType])

WEEKNUM(date,[ReturnType])

EOMONTH(Startdate, Months)

DATEDIFF
RELATED(ColumnName)

CALCULATE(Expression,[Filter1],[Filter2],...)
ALL(table)
FILTER(Table, FilterExpression)
RELATED(columname)

Iteratorx
SUMX(Table, Expression)
COUNTX
AVERAGEX
RANKX
MAXX
MINX

CALCULATE(Measure, DATESYTD(Calendar[Date]))
CALCULATE(Measure, DATEADD(Calendar[Date],-1,MONTH))
CALCULATE(Measure,DATESINPERIOD(Calendar[Date],MAX(Calendar[Date]),-10,DAY))

UNICHAR (######)

COUNT(ColumnName)
COUNTA(ColumnName)
COUNTAX(Table, Expression)
COUNTBLANK(ColumnName)
COUNTROWS(Table)
COUNTX(Table, Expression)
addition
subtraction
multiplication
division
exponent
equal to
greater than
less than
greater than or equal to
less than or equal to
not equal to
"concatenante" two values to produce one string
AND condition
OR condtion. Double pipe ||
logical OR based on a given list. IN {item1, item2,...}

returns the "number" of characters in a string


joins two text strings into one
converts a string to upper case
converts a string to lower case
returns a number of characters starting from the left
returns a number of characters starting from the right
returns a number of characters starting from the mid
replaces an instance of existing text with new text in a string.
[instance_num] is the nth instance of the old text to find.
returns the "position" where a specified string or character is found

returns the current date


returns the current time
returns the day of the date specified (0-31)
returns the month of the date specified (0-12)
returns the year of the date specified (year)
returns the hour (0-23)
returns the minute (0-59)
returns the second (0-59)
returns a weekday number from (1-7).
[ReturnType] is the day you want a week to start
returns the week # of the year (1-52).
[ReturnType] is the day you want a week to start
returns the date of the last day of the month
month is positive+, return the last day of the next month
month is negative-, return the last day of the previous month
returns the difference between two date, based on a given interval (day,hour,year,etc)
returns related values in each row of a table based on relationships with other tables,
vlookup or xlookup of POWER BI
calculate an expression with using a combination of filters
returns or call a whole table into the equation
returns or call a subset of a table filtered by a boolean expression
call a column from another related table.

call a table, solve an expression, then do the wanted aggregation


call a table, solve an expression, then do the wanted aggregation
call a table, solve an expression, then do the wanted aggregation
call a table, solve an expression, then do the wanted aggregation
call a table, solve an expression, then do the wanted aggregation
call a table, solve an expression, then do the wanted aggregation

performance to date. YTD for years, QTD quarters, MTD months.


previous period. DAY, MONTH, QUARTER OR YEAR. -1 is the interval of choice
running total. DAY, MONTH, QUARTER, YEAR. -10 is the length of time you want to total.

call a symbol. used mostly when using concatenate. Search internet UNICHAR codes. Example:
uparrow, downarrow, leftarrow, rightarrow

Count the "numbers" in a specific column


Count the "values" in a specific column
Count the "values" after evaluating an expression for each row of a table
Count the "blanks" in a specific column
Count the "rows" in a table
Count the "values" after evaluating an expression for each row of a table

You might also like