Forum Discussion
Sorting a Date Table with Broadcast Dates
Hi hoyt22 ,
Please check out the steps below:
1. Create the file with date and figure it out:
2. Please check out the effect:
3. Could you please post your sample file here if this couldn’t help you resolve the issue? I can’t open the link you provided. How to provide sample data in the Power BI Forum - Microsoft Fabric Community”
Best regards,
Lucy Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- hoyt221 year ago
Helper I
Anonymous I'm not sure why you can't open my Google Drive link; it looks like another user was able to just fine.
I can't see your full code to see if it would solve my issue, but looking at your chart, you have both January and February selected. However, the Broadcast Week of January 29 should be under the Broadcast Month of February only.
Here's my date table in case it helps. Maybe there's something I'm missing.
let StartDate = #date(2024, 1, 1), EndDate = #date(2024, 12, 31), NumberOfDays = Duration.Days(EndDate - StartDate) + 1, DateList = List.Dates(StartDate, NumberOfDays, #duration(1, 0, 0, 0)), #"Converted to Table" = Table.FromList(DateList, Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error), #"Added Custom Columns" = Table.AddColumn(#"Converted to Table", "Calendar Year", each Date.Year([Date])), #"Added Custom Columns1" = Table.AddColumn(#"Added Custom Columns", "Calendar Quarter", each "Qtr " & Number.ToText(Date.QuarterOfYear([Date]))), #"Added Custom Columns2" = Table.AddColumn(#"Added Custom Columns1", "Calendar Month Number", each Date.Month([Date])), #"Added Custom Columns3" = Table.AddColumn(#"Added Custom Columns2", "Calendar Month", each Date.ToText([Date], "MMMM")), #"Added Custom Columns4" = Table.AddColumn(#"Added Custom Columns3", "Calendar Day", each Date.Day([Date])), #"Added Custom Columns5" = Table.AddColumn(#"Added Custom Columns4", "Broadcast Day", each Date.Day([Date])), #"Added Custom Columns6" = Table.AddColumn(#"Added Custom Columns5", "Broadcast Week", each Date.StartOfWeek([Date], Day.Monday)), #"Added Custom Columns7" = Table.AddColumn(#"Added Custom Columns6", "Broadcast Month", each let // Start of the month for the current date FirstOfNextMonth = Date.StartOfMonth(Date.AddMonths([Date], 1)), // Monday of the week containing the 1st of the next month FirstWeekOfNextMonth = Date.StartOfWeek(FirstOfNextMonth, Day.Monday) in if [Date] >= FirstWeekOfNextMonth then Date.ToText(FirstOfNextMonth, "MMMM") else Date.ToText(Date.StartOfMonth([Date]), "MMMM") ), #"Added Custom Columns8" = Table.AddColumn(#"Added Custom Columns7", "Broadcast Month Number", each List.PositionOf({"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, [Broadcast Month]) + 1 ), #"Added Custom Columns9" = Table.AddColumn(#"Added Custom Columns8", "Broadcast Quarter", each if [Broadcast Month] = "January" or [Broadcast Month] = "February" or [Broadcast Month] = "March" then "Qtr 1" else if [Broadcast Month] = "April" or [Broadcast Month] = "May" or [Broadcast Month] = "June" then "Qtr 2" else if [Broadcast Month] = "July" or [Broadcast Month] = "August" or [Broadcast Month] = "September" then "Qtr 3" else if [Broadcast Month] = "October" or [Broadcast Month] = "November" or [Broadcast Month] = "December" then "Qtr 4" else null ), #"Added Custom Columns10" = Table.AddColumn(#"Added Custom Columns9", "Broadcast Year", each if [Date] >= Date.StartOfWeek(Date.AddDays(Date.StartOfMonth(Date.AddMonths([Date], 1)), -Date.DayOfWeek(Date.StartOfMonth(Date.AddMonths([Date], 1)), Day.Monday)), Day.Monday) then Date.Year(Date.AddMonths([Date], 1)) else Date.Year([Date]) ), #"Changed Type" = Table.TransformColumnTypes(#"Added Custom Columns10",{{"Date", type date}, {"Broadcast Month Number", Int64.Type}, {"Calendar Month Number", Int64.Type}, {"Broadcast Week", type date}}) in #"Changed Type"I appreciate your help!