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.
Hello, I am looking to create a new row in power query editor data that will give my numeric figures based on if the criteria is set between 2 times going by HH:MM format. For instance I am wanting get a 1 added into a new column for when the criteria is between 00:00 - 00:15.
I have tried to search on here and the web and have found nothing for what I am trying to create.
I have tried out the following:
Custom Column created = IF [ColumnA] => 00:00 AND [ColumnA] <= 00:15 then 1 else 0.
I am getting errors and dont know where to go. Column A with the time values in all are set as "Time" values at the header of the column. Any help would be gratefully appreciated?
Thanks,
Alex
Solved! Go to Solution.
Hi, @alexw94
According to your description, you want to add a column (1,0) judged by the criteria is between 00:00 - 00:15. Right?
Here are the steps you can refer to :
(1)This is my test data:
(2)And we also change the date type to "Time":
(3)Then we can add a custom column and enter this:
if [Time] >= Time.From("00:00") and [Time] <= Time.From("00:15") then 1 else 0
(4)Then we can meet your need:
The whole M code is like this , you can put in the "Advanced Editor" to refer to :
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjCwMjRVitUBswwMYCxDI7iYBVzMDMYyNoawDK0MTSAsCysjiA5DYzArFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", type time}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Time] >= Time.From("00:00") and [Time] <= Time.From("00:15") then 1 else 0)
in
#"Added Custom"
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi, @alexw94
According to your description, you want to add a column (1,0) judged by the criteria is between 00:00 - 00:15. Right?
Here are the steps you can refer to :
(1)This is my test data:
(2)And we also change the date type to "Time":
(3)Then we can add a custom column and enter this:
if [Time] >= Time.From("00:00") and [Time] <= Time.From("00:15") then 1 else 0
(4)Then we can meet your need:
The whole M code is like this , you can put in the "Advanced Editor" to refer to :
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjCwMjRVitUBswwMYCxDI7iYBVzMDMYyNoawDK0MTSAsCysjiA5DYzArFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", type time}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Time] >= Time.From("00:00") and [Time] <= Time.From("00:15") then 1 else 0)
in
#"Added Custom"
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
62 | |
52 | |
39 | |
24 |
User | Count |
---|---|
85 | |
57 | |
45 | |
44 | |
36 |