Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Bakhtawar
Post Patron
Post Patron

User defined calendar table in power bi

I am trying to add calendar table in power bi .. here how i add

    Calender = ADDCOLUMNS(CALENDAR (DATE(1995,5,1), DATE(2019,12,31)),
"Year",FORMAT([Date],"YYYY"),"Quarter","Q" &FORMAT([Date],"Q"),
"Month",FORMAT([Date],"MM"),"MonthName",FORMAT([Date],"MMM"),"Monthnumber", FORMAT ([Date], "MM" ),
"YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek",FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ))

check this picture

 

and these are more tables

z1hmc

 

now i want to ask how i add and link datekey in orders_Fact table where there is no column of datekey in fact table.. i manually create it by query .. when i click on edit queries from home tab then i did not find calendar table in this panel

 

Kczs7

 

this is the file link https://www.dropbox.com/s/tdsf0xhogr4opgr/test_fle.pbix?dl=0

3 REPLIES 3
jdbuchanan71
Super User
Super User

Hello @Bakhtawar 

Not sure I understand.  You can just drag the date key to the order date on the fact table to make the relationship:

DateKey.jpg

I would also change your calendar table to start on Jan 1st.

Calender = ADDCOLUMNS(CALENDAR (DATE(1995,1,1), DATE(2019,12,31)),

but when i search northwind database star scehma this shows that date key and order date is totally different ... i have to add datekey in order fact table .. i dont want to link datekey with orderdate. 

check below image

 

1.JPG

That's because that key uses a YYYYMMDD format I believe but it you have a date in your calendar and a date in your order table you can link using that.  What date do you want to use in your fact table if not the order date?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.