Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello!
I am VERY new to Power BI. I am working on building a simple Date Table and I need help with adding a column for our Sales Month.
Currently, our Sales Month begins on the Sunday after the 1st Saturday of the Month and ends on the 1st Saturday of the next month - so... Sales Month for June begins on Sunday, June 6, 2021 and ends on Saturday, July 3, 2021.
Using Power Query, how can I add this Sales Month column to my Date Table and have it populate correctly?
Thanks in advance for your help!
DB
Solved! Go to Solution.
This worked perfectly, thank you!
Hi @dbethart
Here is one way, paste it to Advaned Editor with a blank query
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VdGxDYNAAATBXogt8XfYvF0Lov82MAHBhJuNtMexjKxjXzua5Xz9s+Zmvs2PuZvT/Jo/MsNUFVVRFVVRFVVRFVVRVVVVVVVVVVVVVVVVVVVVtam6D04PTg9ODz55Xg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Inserted Day of Week" = Table.AddColumn(#"Changed Type", "Day of Week", each Date.DayOfWeek([Date],0), Int64.Type),
#"Inserted Month" = Table.AddColumn(#"Inserted Day of Week", "Month", each Date.Month([Date]), Int64.Type),
#"Filtered Rows" = Table.SelectRows(#"Inserted Month", each ([Day of Week] = 0)),
#"Grouped Rows" = Table.Group(#"Filtered Rows", {"Month"}, {{"Start", each List.Min([Date]), type nullable date}}),
#"Merged Queries" = Table.NestedJoin(#"Inserted Month", {"Month"}, #"Grouped Rows", {"Month"}, "Grouped Rows", JoinKind.LeftOuter),
#"Added Custom" = Table.AddColumn(#"Merged Queries", "Sales Month", each if [Date]<[Grouped Rows][Start]{0} then [Month]-1 else [Month]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Grouped Rows"})
in
#"Removed Columns"
Hi, @Vera_33!
Thank you for putting this together for me. I'm having a few issues:
Hi @dbethart
The query is for your refernce, you go with your own data, start from #"Inserted Month"(it's in the UI, you can click) with Month...you don't need to use the sample data I put in the query, use your own
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 10 | |
| 6 | |
| 5 | |
| 4 | |
| 2 |