Forum Discussion
Anonymous
7 years agoNot applicable
DATES Table - relationship not working completely
Hi guys, I am new to BI and playing with some data. I have historical data with order history for last year (order ref, datecreated (as datetime), amount - which is loaded via a query. As I need mo...
PiyushZope
7 years agoFrequent Visitor
Hello,
I think you are making a mistake while creating a calendar. why don't you follow the attached video and create the calendar and try if it works or not?
Here is the sample code which is used in the video.
let
Source = (Start_Date as date, End_date as date) =>
let
StartDate = (Start_Date),
EndDate = (End_date),
DurationofDays = Duration.Days(End_date - Start_Date),
Dates = List.Dates(Start_Date,DurationofDays+1, #duration(1,0,0,0)),
#"Converted to Table" = Table.FromList(Dates, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type date}}),
#"Inserted Year" = Table.AddColumn(#"Changed Type", "Year", each Date.Year([Column1]), Int64.Type),
#"Inserted Month" = Table.AddColumn(#"Inserted Year", "Month", each Date.Month([Column1]), Int64.Type),
#"Inserted Quarter" = Table.AddColumn(#"Inserted Month", "Quarter", each Date.QuarterOfYear([Column1]), Int64.Type),
#"Inserted Week of Year" = Table.AddColumn(#"Inserted Quarter", "Week of Year", each Date.WeekOfYear([Column1]), Int64.Type),
#"Inserted Day" = Table.AddColumn(#"Inserted Week of Year", "Day", each Date.Day([Column1]), Int64.Type),
#"Inserted Week of Month" = Table.AddColumn(#"Inserted Day", "Week of Month", each Date.WeekOfMonth([Column1]), Int64.Type),
#"Inserted Month Name" = Table.AddColumn(#"Inserted Week of Month", "Month Name", each Date.MonthName([Column1]), type text),
#"Inserted Day Name" = Table.AddColumn(#"Inserted Month Name", "Day Name", each Date.DayOfWeekName([Column1]), type text)
in
#"Inserted Day Name"
in
Source