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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
AdamHurleyEI
Frequent Visitor

Calendar Lookup Table - Dates Disappearing in 'Table View'

I built a calendar lookup table using the following MCode:

let
// Start and end dates for the calendar table
StartDate = #date(2018, 1, 1),
EndDate = DateTime.Date(DateTime.LocalNow()),

// Number of days in the calendar table
NumberOfDays = Duration.Days(EndDate - StartDate) + 1,

// Generate a list of dates
DatesList = List.Dates(StartDate, NumberOfDays, #duration(1, 0, 0, 0)),

// Convert the list of dates to a table
CalendarTable = Table.FromList(DatesList, Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error),
#"Changed Type" = Table.TransformColumnTypes(CalendarTable,{{"Date", type date}}),
#"Inserted Day" = Table.AddColumn(#"Changed Type", "Day", each Date.Day([Date]), Int64.Type),
#"Inserted Day of Week" = Table.AddColumn(#"Inserted Day", "Day of Week", each Date.DayOfWeek([Date]), Int64.Type),
#"Inserted Day Name" = Table.AddColumn(#"Inserted Day of Week", "Day Name", each Date.DayOfWeekName([Date]), type text),
#"Added Conditional Column" = Table.AddColumn(#"Inserted Day Name", "Time of Week", each if [Day of Week] < 5 then "Weekday" else "Weekend"),
#"Inserted Start of Week" = Table.AddColumn(#"Added Conditional Column", "Start of Week", each Date.StartOfWeek([Date]), type date),
#"Inserted Week of Year" = Table.AddColumn(#"Inserted Start of Week", "Week of Year", each Date.WeekOfYear([Date]), Int64.Type),
#"Inserted Quarter" = Table.AddColumn(#"Inserted Week of Year", "Quarter", each Date.QuarterOfYear([Date]), Int64.Type),
#"Added Conditional Column1" = Table.AddColumn(#"Inserted Quarter", "Quarter of Year", each if [Quarter] = 1 then "Q1" else if [Quarter] = 2 then "Q2" else if [Quarter] = 3 then "Q3" else if [Quarter] = 4 then "Q4" else null),
#"Inserted Month" = Table.AddColumn(#"Added Conditional Column1", "Month", each Date.Month([Date]), Int64.Type),
#"Inserted Start of Month" = Table.AddColumn(#"Inserted Month", "Start of Month", each Date.StartOfMonth([Date]), type date),
#"Inserted Month Name" = Table.AddColumn(#"Inserted Start of Month", "Month Name", each Date.MonthName([Date]), type text),
#"Inserted Year" = Table.AddColumn(#"Inserted Month Name", "Year", each Date.Year([Date]), Int64.Type)
in
#"Inserted Year"


and this works as expected in the Power Query:

AdamHurleyEI_0-1715188499722.png


When I close and apply and look at the table in 'Table View' it is removing half the dates and I have no idea why?

AdamHurleyEI_1-1715188593623.png


I have no relationships set up:

AdamHurleyEI_2-1715188624812.png

 

1 ACCEPTED SOLUTION
Wilson_
Super User
Super User

Hi Adam,

 

The loaded date table may just not be sorted. If you search the Date column for "02 January 2018" (or search for 1/2/2018 in the below), does it pop up?

 

Wilson__0-1715215473411.png


----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)

 

P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

3 REPLIES 3
Wilson_
Super User
Super User

Hi Adam,

 

The loaded date table may just not be sorted. If you search the Date column for "02 January 2018" (or search for 1/2/2018 in the below), does it pop up?

 

Wilson__0-1715215473411.png


----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)

 

P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Good spot:

AdamHurleyEI_0-1715241716825.png


Of course it was something stupid lol! Thank you

Perfect. I love it when it's user error; those are usually the quickest fixes haha




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.