1 Year
= 12 Months
= 54 Weeks
= 365 Days
Time Intelligence
needs date table.- Must contain all the dates ( days ) for the year ( no gap )
- Must have atleast one field set as a
Date
orDateTime
datatype. - Cannot contain duplicate
Date
orDateTime
values. - If using
Time
component withinDate
column, all times must be identical ( i.e12:00:00 AM
) - Should be marked as a
Date
table. - If
Time
is present inDate
field, split theTime
component into a new column. - Starting from
1st
January to31st
December ( Even if the data is not present from 1st January ) - Including every quarter, month, week, day.
- Otherwise
Time Intelligence
will not work. - Power BI little bit helps to build the Date table but create manually for accuracy.
Auto
date / time : Power BI engine automatically creates date and time table in the background.- But it only considers the dates available in the tables ( Order date, Delivery date, Birthdate, etc )
- And we cannot customize the auto generated date and time.
- The range it selects is unpredective ( Starting Date will be the Birtdate of a Customer which can be more than 100 years )
Returns a table with one column of all dates between Start
and End
date.
CALENDAR (
DATE ( 2021, 01, 01 ),
DATE ( 2021, 12, 31 )
)
We can also allow the table to take reference from existing table for Start
and End
dates.
CALENDAR (
MIN ( 'Order Date' ),
MAX ( 'Order Date' )
)
CALENDAR (
DATE ( YEAR ( MIN ( Calendar[Transaction Date] ) ), 01, 01 ),
DATE ( YEAR ( MAX ( Calendar[Transaction Date] ) ), 12, 31 )
)
- Returns a table with one column of dates based on a Fiscal year end month.
Range
of dates is calculated automatically based on data in the model.
CALENDARAUTO ( FiscalYearEndMonth )
// Fiscal Year End Month : 1 to 12 ( 1 - January, 2 - February .... 12 - December )
- Useful for
Aggregating
date over time orComparing
date over time. YTD
: Year To DateQTD
: Quarter To DateMTD
: Month To Date- They all need a
Date Table
andCALCULATE
function. Running
Total- Same Period
Working
DayFiscal
Year
- Compare current year sales with previous or last year sales.
CALCULATE (
[Sales Amount], // Evaluate Sales Amount
DATEADD (
Date[Date], // Date
-1, // Number of Interval ( - Past, + Future )
YEAR // Interval ( YEAR, QUARTER, MONTH, DAY )
)
)
SAMEPERIODLASTYEAR
: Compare or Calculate the sales for the same period of last year ( Goes back 1 year )
PARALLELPERIOD
:
PREVIOUSYEAR
PREVIOUSQUARTER
PREVIOUSMONTH
- Returns all the dates in a given number of periods, starting from a reference date.
- Moving
Annual
Total.
CALCULATE (
[Sales Amount],
DATESINPERIOD (
Date[Date],
MAX ( Date[Date] ), // Reference Start Date
-1,
YEAR
)
)
- There is no function to Calculate the
Runnning Total
- We need to manually create a
Filter
for evaluating theRunning Total
Running Total
: Sum of Sales Amount since the beginning of the history of the transactions.