Forum Discussion

viwinski7's avatar
viwinski7
Frequent Visitor
5 years ago
Solved

Need to Automatically Filter by Week and Time Range

Hello Power BI Community,    My current client is asking if we could provide them a calculation in the form of a proportion below:    # of clients discharged from Sunday-Sunday 5pm-5pm/ # of tota...
  • v-yalanwu-msft's avatar
    5 years ago

    Hi viwinski7 ,  

    You could modify the MaxArrival2 column by the following formula:

    count =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            [ExitDate/Time] = BLANK ()
                || (
                    WEEKNUM ( [ExitDate/Time] ) = WEEKNUM ( TODAY () )
                        && (
                            (
                                WEEKDAY ( [ExitDate/Time], 2 ) = 6
                                    && TIMEVALUE ( [ExitDate/Time] ) < TIMEVALUE ( "17:00:01" )
                            )
                                || (
                                    WEEKDAY ( [ExitDate/Time], 2 ) = 7
                                        && TIMEVALUE ( [ExitDate/Time] ) >= TIMEVALUE ( "17:00:00" )
                                )
                                || ( WEEKDAY ( [ExitDate/Time], 2 ) IN { 1, 2, 3, 4, 5 } )
                        ))))
    

    The final output is shown below:  

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.