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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
keboon
Employee
Employee

Missing Hours of the Day

Hi All:

 

I am trying to tell Power Bi to find the missing Hours of the Day for Time Scheduling Ads.  As you can see there is a gap between 4-8am on Sunday.  Is there a formula or process to tell Power Bi that Sunday 4-8 am is the missing time?

DayStart HourEnd Hour
Sunday04
Sunday812
Sunday1216
Sunday1620
Sunday2024
1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @keboon ,

Please try:

Column = 
VAR _end =
    CALCULATE (
        MAX ( 'Table'[End Hour] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Day] = EARLIER ( 'Table'[Day] )
                && 'Table'[Start Hour] < EARLIER ( 'Table'[Start Hour] )
        )
    )
VAR _result =
    IF ( 'Table'[Start Hour] <> _end, 'Table'[Start Hour] - _end )
RETURN
    _result

vcgaomsft_0-1671176610086.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

4 REPLIES 4
v-cgao-msft
Community Support
Community Support

Hi @keboon ,

Please try:

Column = 
VAR _end =
    CALCULATE (
        MAX ( 'Table'[End Hour] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Day] = EARLIER ( 'Table'[Day] )
                && 'Table'[Start Hour] < EARLIER ( 'Table'[Start Hour] )
        )
    )
VAR _result =
    IF ( 'Table'[Start Hour] <> _end, 'Table'[Start Hour] - _end )
RETURN
    _result

vcgaomsft_0-1671176610086.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thank you! Now suppose I have multiple dates like Sunday, Monday, Tuesday, etc and multiple missing times.  How does the formula changes to accommodate the different dates and times?

Greg_Deckler
Super User
Super User

@keboon Try:

Measure = 
  VAR __Day = MAX('Table'[Day])
  VAR __Start = MAX('Table'[Start Hour])
  VAR __End = MAX('Table'[End Hour])
  VAR __StartHours = SELECTCOLUMNS('Table',"__Start",[Start Hour])
  VAR __EndHours = SELECTCOLUMNS('Table',"__End",[End Hour])
  VAR __MissingEnd = IF(__End IN __StartHours, BLANK(), __End)
  VAR __MissingStart = IF(__Start IN __EndHours, BLANK(), __Start)
  VAR __Result = IF( __MissingEnd = BLANK() && __MissingStart = BLANK(), BLANK(), __Day & " " & __MissingEnd & "-" & __MissingStart)
RETURN
  __Result

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you! Now suppose I have multiple dates like Sunday, Monday, Tuesday, etc and multiple missing times.  How does the formula changes to accommodate the different dates and times?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.