Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a Sub Date column that simply has dates: 1/1/2020, 1/16/2020, etc. I want to add a custom column in the query that checks IF the date is between first of the month to the 8th of the month, and if so, set value to either TRUE or 1 to signify it's within that date range
How can I achieve this in M?
Solved! Go to Solution.
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may add a custom column with the following m codes.
=if Date.Day([Sub Date])>=1 and Date.Day([Sub Date])<=8
then 1 else 0
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may add a custom column with the following m codes.
=if Date.Day([Sub Date])>=1 and Date.Day([Sub Date])<=8
then 1 else 0
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @Anonymous ,
Please find the steps to achieve the result in query editor.
let
Source = Excel.Workbook(File.Contents("C:\Users\kgawale\Documents\Test 15 March 2021.xlsx"), null, true),
Sheet7_Sheet = Source{[Item="Sheet7",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet7_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Contract Date", type date}}),
#"Inserted Month" = Table.AddColumn(#"Changed Type", "Month", each Date.Month([Contract Date]), Int64.Type),
#"Added Conditional Column" = Table.AddColumn(#"Inserted Month", "Custom.1", each if [Month] <= 8 then 1 else 0)
in
#"Added Conditional Column"
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
73 | |
72 | |
38 | |
31 | |
26 |