Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
85 | |
68 | |
59 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |