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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
android1
Post Patron
Post Patron

Filter between hours in the day

Hi,

 

This calc column 8AM-10PM = IF(HOUR(vw_PivotChargesFrontPage[Visits_StartTime]) >= 8  && HOUR(vw_PivotChargesFrontPage[Visits_EndTime]) <= 22 ,TRUE(),FALSE())

 

returns all calls with a start time on or after 8am & an end time on or before 10pm. Problem is it also returns calls with an end time between 10pm & 10:59pm. In pic below I do not want 22:55, 22: 50 etc

 

If I add && Minute(vw_PivotChargesFrontPage[Visits_EndTime]) <= 0 then it will exclude calls that end at 8:30am, 19:55 etc 

which I don't want.

 

2018-07-11 13_59_46-Invitation to Tender Call Analysis - Power BI Desktop.jpg

2 ACCEPTED SOLUTIONS

Would need sample data posted that I can copy and paste, just been hacking up to this point.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

@android1,

 

Add the following Boolean expression as well.

    vw_PivotChargesFrontPage[Visits_StartTime]
        <= vw_PivotChargesFrontPage[Visits_EndTime]
Community Support Team _ Sam Zha
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

9 REPLIES 9
Greg_Deckler
Community Champion
Community Champion

8AM-10PM = IF(HOUR(vw_PivotChargesFrontPage[Visits_StartTime]) >= 8  && HOUR(vw_PivotChargesFrontPage[Visits_EndTime]) <= 21 ,TRUE(),FALSE())


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

Thanks for the feedback.

 

What about calls with an end time of 22:00. They won't be included if I use <=21.

 

I'd like all calls returned with a start time from 8am onwards & with an end time of 22:00 at the latest.

 

Expected results ->

 

2018-07-11 16_16_08-Office Ext  & Mob Numbers Draft  [Read-Only] - Excel.jpg

8AM-10PM = 
IF(
     HOUR(vw_PivotChargesFrontPage[Visits_StartTime]) >= 8  
&&
(
HOUR(vw_PivotChargesFrontPage[Visits_EndTime]) <= 21
||
(
HOUR(vw_PivotChargesFrontPage[Visits_EndTime]) = 22
&&
MINUTE(vw_PivotChargesFrontPage[Visits_EndTime]) = 0)
)
),
TRUE(),
FALSE()
)

Maybe.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Oops, inadvertantly accepted as solution.

 

Not quite returning what I need.

 

2018-07-11 20_00_55-Invitation to Tender Call Analysis WIP - Power BI Desktop.png

@android1,

 

Add the following Boolean expression as well.

    vw_PivotChargesFrontPage[Visits_StartTime]
        <= vw_PivotChargesFrontPage[Visits_EndTime]
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes, thank you. @Greg_Deckler Your code works perfectly with the added expression from @v-chuncz-msft

Cool! The power of teamwork!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Would need sample data posted that I can copy and paste, just been hacking up to this point.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.