This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hello,
I am trying to create a custom column with the below requirements:
1) If the Month has more than 30 days, then the quarter should be the same until the next Sunday date
2) Else return the next quarter
This is an example of what I have now
I am looking for:
(March 2022 had 31 days and the next Sunday was 04/03 therefore any day up until the next Sunday (04/03) should be Quarter 1)
W/E Company First Processed Quarter Num Quarter Num.1
| 2/6/2022 | 1 | Q1-2022 |
| 2/13/2022 | 1 | Q1-2022 |
| 2/20/2022 | 1 | Q1-2022 |
| 2/27/2022 | 1 | Q1-2022 |
| 3/6/2022 | 1 | Q1-2022 |
| 3/13/2022 | 1 | Q1-2022 |
| 3/20/2022 | 1 | Q1-2022 |
| 3/27/2022 | 1 | Q1-2022 |
| 4/3/2022 | 1 | Q1-2022 |
| 4/10/2022 | 2 | Q2-2022 |
| 4/17/2022 | 2 | Q2-2022 |
| 4/24/2022 | 2 | Q2-2022 |
| 5/1/2022 | 2 | Q2-2022 |
| 5/8/2022 | 2 | Q2-2022 |
Solved! Go to Solution.
Hi, @Brite ;
You add custom in powerbi query.
[date]-#duration(1,0,0,0)= Table.AddColumn(#"Added Custom", "Start of Week", each Date.StartOfWeek([Custom])+#duration(1,0,0,0))= Table.AddColumn(#"Inserted Start of Week", "Quarter1", each Date.QuarterOfYear([Start of Week]), Int64.Type)= Table.RemoveColumns(#"Inserted Quarter",{"Custom", "Start of Week"})
M lanuage:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc1BCoAwDETRq0jWlTSTaL1G16X3v0atiCAkXWQRHsxvjcAnIwMbJZL7quzzpZ6miT7oGvLCSmT69lyKc7rI6SJnHE4ayzc5r+JnJTZYZAdLTJdLfQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"W/E Company" = _t, num = _t, Quarter = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"W/E Company", type date}, {"num", Int64.Type}, {"Quarter", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"W/E Company", "date"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "Custom", each [date]-#duration(1,0,0,0)),
#"Inserted Start of Week" = Table.AddColumn(#"Added Custom", "Start of Week", each Date.StartOfWeek([Custom])+#duration(1,0,0,0)),
#"Inserted Quarter" = Table.AddColumn(#"Inserted Start of Week", "Quarter1", each Date.QuarterOfYear([Start of Week]), Int64.Type),
#"Removed Columns1" = Table.RemoveColumns(#"Inserted Quarter",{"Custom", "Start of Week"})
in
#"Removed Columns1"
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Brite ;
You add custom in powerbi query.
[date]-#duration(1,0,0,0)= Table.AddColumn(#"Added Custom", "Start of Week", each Date.StartOfWeek([Custom])+#duration(1,0,0,0))= Table.AddColumn(#"Inserted Start of Week", "Quarter1", each Date.QuarterOfYear([Start of Week]), Int64.Type)= Table.RemoveColumns(#"Inserted Quarter",{"Custom", "Start of Week"})
M lanuage:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc1BCoAwDETRq0jWlTSTaL1G16X3v0atiCAkXWQRHsxvjcAnIwMbJZL7quzzpZ6miT7oGvLCSmT69lyKc7rI6SJnHE4ayzc5r+JnJTZYZAdLTJdLfQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"W/E Company" = _t, num = _t, Quarter = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"W/E Company", type date}, {"num", Int64.Type}, {"Quarter", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"W/E Company", "date"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "Custom", each [date]-#duration(1,0,0,0)),
#"Inserted Start of Week" = Table.AddColumn(#"Added Custom", "Start of Week", each Date.StartOfWeek([Custom])+#duration(1,0,0,0)),
#"Inserted Quarter" = Table.AddColumn(#"Inserted Start of Week", "Quarter1", each Date.QuarterOfYear([Start of Week]), Int64.Type),
#"Removed Columns1" = Table.RemoveColumns(#"Inserted Quarter",{"Custom", "Start of Week"})
in
#"Removed Columns1"
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 27 | |
| 25 | |
| 25 | |
| 21 | |
| 14 |
| User | Count |
|---|---|
| 50 | |
| 44 | |
| 20 | |
| 18 | |
| 18 |