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
I am trying to create a visual that will so how many items were inspected during a certain time period.
I'm thinking the easiest way to do this is create another column that will have TimeName, then I can create a visual that will count the TimeName during a day. How do I create the column based on the records time being between two other times? Or is there a better way of doing this. A sample of the time is below.
Solved! Go to Solution.
Hi @hllary ,
Here are the steps you can follow:
1. Create calculated column.
Flag =
CALCULATE(MIN('Table'[TimeName]),filter('Table',[start]<=earlier('Table2'[date_insp_time]) &&[end]>= earlier('Table2'[date_insp_time])))
New Column =
var _count=
COUNTX(FILTER( ALL('Table2'),'Table2'[Flag]=EARLIER('Table2'[Flag])),[Flag])
return
[Flag] &" "&_count&" Project"
2. Result:
Please click here for the pbix file
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @hllary ,
Here are the steps you can follow:
1. Create calculated column.
Flag =
CALCULATE(MIN('Table'[TimeName]),filter('Table',[start]<=earlier('Table2'[date_insp_time]) &&[end]>= earlier('Table2'[date_insp_time])))
New Column =
var _count=
COUNTX(FILTER( ALL('Table2'),'Table2'[Flag]=EARLIER('Table2'[Flag])),[Flag])
return
[Flag] &" "&_count&" Project"
2. Result:
Please click here for the pbix file
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Time Table
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjFQ0lEytjIwACIgywzKitUBShkiCegoWSBLGSEJ6CgZGiDLGSOLAJlGVsYISRNkESDTBCYZCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Time Key" = _t, Start = _t, End = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Time Key", type text}, {"Start", type time}, {"End", type time}})
in
#"Changed Type"
Time Data
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjSyMjKwMjBQitUBcoyROGZWhqZwCQMrY4QqEysjiEwsAA==", 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", "Add Time Key", (x) => Table.SelectRows(#"Time Table", each x[Time] >= [Start] and x[Time] < [End] ){0}[Time Key] , type text)
in
#"Added Custom"you can try to create a column
maxx(filter(table1,start<=DATE_INSP_Time&&end>=DATE_INSP_Time),TimeName)
Proud to be a Super User!
Hi @hllary - I have created the following PBIX example to show how you can use Power Query syntax to find the Time Band. Sample File . Please note the range removes the +1 second from the time ranges.
Thanks for you help! This project is for work and they have an older version of power bi. Please post the the code to the power query. thanks
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 37 | |
| 28 | |
| 25 |
| User | Count |
|---|---|
| 124 | |
| 87 | |
| 70 | |
| 66 | |
| 65 |