Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
table name : AW_Fact_Sales
field NAME: OrderDate
The first orderdate is 15 – October 2001
The last orderdate is 29 – Nov 2019.
WANT TO CREATE A DATE FIELD IN MY CALEDER TABLE USING THE ABOVE VALUES AS MY STARTDATE AND ENDDATE
The below fields are in calendar table and they are generating dates of 1900
Date5 =
CALENDAR(FIRSTDATE(AW_Fact_Sales[OrderDate].[Date]),LASTDATE(AW_Fact_Sales[OrderDate].[Date]))
DATE 2 CALENDAR(FIRSTDATE(AW_Fact_Sales[OrderDate]),LASTDATE(AW_Fact_Sales[OrderDate]))
Even this field below is generating dates of 1900.
date4 = CALENDAR(15/10/2001,29/11/2019)
.WHY?
Solved! Go to Solution.
You can create a calendar table using DAX code like the following:
@Likando_Luywa
Specify the start and end date and ensure the dates table has data for the whole year. You use below code for your Dates table creation,
Dates =
VAR StartYear = YEAR( MIN(Orders[Order Date]) )
VAR EndYear = YEAR( MAX(Orders[Order Date]) )
VAR DatesColumn = CALENDAR( DATE(StartYear , 1 , 1), DATE(EndYear, 12 , 31))
RETURN
ADDCOLUMNS(
DatesColumn,
"Month No" , MONTH([Date]),
"Month Name" , FORMAT( [Date] , "Mmmm" ),
"Year" , YEAR([Date]),
"Month Year No" , (YEAR([Date]) * 100) + MONTH([Date]),
"Month Year" , FORMAT( [Date] , "Mmm yyyy"),
"Quarter" , QUARTER([Date]),
"Qtr Name" , FORMAT( [Date] , "\QQ"),
"Week Day" , WEEKDAY([Date],2),
"Week" , FORMAT( [Date] , "Dddd" ),
"Week No" , WEEKNUM([Date],2),
"Week Num" , "WK - " & WEEKNUM([Date],2)
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
This article/video explains how to do this in the query editor or with DAX. And it creates columns that do not need Sort By Columns (e.g., Month, YearMonth).
No Sort Date Tables! – Hoosier BI
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@Likando_Luywa
Specify the start and end date and ensure the dates table has data for the whole year. You use below code for your Dates table creation,
Dates =
VAR StartYear = YEAR( MIN(Orders[Order Date]) )
VAR EndYear = YEAR( MAX(Orders[Order Date]) )
VAR DatesColumn = CALENDAR( DATE(StartYear , 1 , 1), DATE(EndYear, 12 , 31))
RETURN
ADDCOLUMNS(
DatesColumn,
"Month No" , MONTH([Date]),
"Month Name" , FORMAT( [Date] , "Mmmm" ),
"Year" , YEAR([Date]),
"Month Year No" , (YEAR([Date]) * 100) + MONTH([Date]),
"Month Year" , FORMAT( [Date] , "Mmm yyyy"),
"Quarter" , QUARTER([Date]),
"Qtr Name" , FORMAT( [Date] , "\QQ"),
"Week Day" , WEEKDAY([Date],2),
"Week" , FORMAT( [Date] , "Dddd" ),
"Week No" , WEEKNUM([Date],2),
"Week Num" , "WK - " & WEEKNUM([Date],2)
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
You can create a calendar table using DAX code like the following:
User | Count |
---|---|
115 | |
95 | |
87 | |
76 | |
65 |
User | Count |
---|---|
138 | |
113 | |
110 | |
98 | |
93 |