Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
jdb9294
Frequent Visitor

How to filter a report using time

I have a table that includes incidents and captures the date and time of the incident.

 

I have a report that counts various things related to that incident.

 

I want to use a slicer to filter this report by date and time.

 

For example, I want to see all the incidents that happened between 1/1/2019 0800 to 01/07/2019 1600.  I would want all incidents that occurred from that start date\time to the end.  So an incident on 1/2/2019 0700 would be included.

 

I have included a screenshot to show how my data is currently stored.

 

Capture.PNG

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @jdb9294 

In Edit queries, create two tables

Capture2.JPG

Date table, code in Advanced editor

 

let 
    startdate=#date(2019,1,1),
    today=DateTime.Date(DateTime.LocalNow()),
    length=Duration.Days(today-startdate),  
    Source = List.Dates(startdate,length,#duration(1,0,0,0)),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Date"}})
in
    #"Renamed Columns"

 

Time table

 

let
    Source = List.Times(#time(0,0,0),24,#duration(0,0,60,0)),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "time"}}),
    #"Inserted Hour" = Table.AddColumn(#"Renamed Columns", "Hour", each Time.Hour([time]), Int64.Type)
in
    #"Inserted Hour"

 

 

Close&&apply

Capture3.JPG

Create a measure and add it into the visual level filter

 

Measure =
IF (
    MIN ( 'Date'[Date] ) < MAX ( 'Table'[call date] )
        && MAX ( 'Table'[call date] ) < MAX ( 'Date'[Date] ),
    1,
    IF (
        (
            MAX ( 'Table'[call date] ) = MIN ( 'Date'[Date] )
                && HOUR ( MAX ( 'Table'[call time] ) ) >= MIN ( 'Time'[Hour] )
        )
            || (
                MAX ( 'Table'[call date] ) = MAX ( 'Date'[Date] )
                    && HOUR ( MAX ( 'Table'[call time] ) ) <= MAX ( 'Time'[Hour] )
            ),
        1,
        0
    )
)

 

Capture1.JPG

Capture8.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-juanli-msft
Community Support
Community Support

Hi @jdb9294 

In Edit queries, create two tables

Capture2.JPG

Date table, code in Advanced editor

 

let 
    startdate=#date(2019,1,1),
    today=DateTime.Date(DateTime.LocalNow()),
    length=Duration.Days(today-startdate),  
    Source = List.Dates(startdate,length,#duration(1,0,0,0)),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Date"}})
in
    #"Renamed Columns"

 

Time table

 

let
    Source = List.Times(#time(0,0,0),24,#duration(0,0,60,0)),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "time"}}),
    #"Inserted Hour" = Table.AddColumn(#"Renamed Columns", "Hour", each Time.Hour([time]), Int64.Type)
in
    #"Inserted Hour"

 

 

Close&&apply

Capture3.JPG

Create a measure and add it into the visual level filter

 

Measure =
IF (
    MIN ( 'Date'[Date] ) < MAX ( 'Table'[call date] )
        && MAX ( 'Table'[call date] ) < MAX ( 'Date'[Date] ),
    1,
    IF (
        (
            MAX ( 'Table'[call date] ) = MIN ( 'Date'[Date] )
                && HOUR ( MAX ( 'Table'[call time] ) ) >= MIN ( 'Time'[Hour] )
        )
            || (
                MAX ( 'Table'[call date] ) = MAX ( 'Date'[Date] )
                    && HOUR ( MAX ( 'Table'[call time] ) ) <= MAX ( 'Time'[Hour] )
            ),
        1,
        0
    )
)

 

Capture1.JPG

Capture8.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ChrisMendoza
Resident Rockstar
Resident Rockstar

@jdb9294 -

Pretty sure the best practice is to use a Time Dimenison table related to your [CallTime]. https://www.biinsight.com/time-dimension-in-power-bi-and-ssas-tabular-model-supporting-minutes-time-... shows how you can create a table.






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Thanks for the link.  I have the table created and related to my call time, but I am still not sure how to get a slider to do what I want it to do here...

@jdb9294 -

I put this mock-up together, which part are you getting stuck at?

11.png12.png13.png14.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Thank you so much for this help by the way!


Let's use your last screenshot, I think the problem I still have is let's say there is a record with a date of 11/14/2019 at 0900. Will that be picked up?

 

It seems you are only seeing calls that occurred between the hours of 1700 and 1859 on each day.

@jdb9294 -

Ah, I see what you mean. I've never really had a need for a dimTime so I'm really just learning alongside you.  I found this https://www.blue-granite.com/blog/disconnected-table-power-bi and thought about using the SELECTEDVALUE to find out what is selected in the slicer, haven't quite got anything really going. The idea would be to find the minimum datetime stamp and the maximum datetime stamp then getting the results inbetween. I don't know if its the best way, it's just the first thing I thought about.






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.