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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
bmccaslin
Regular Visitor

Filtering Sales Data Between Friday 5pm - Monday 4am

Hello, 

 

 I'm currently looking to filter out sales data that falls between Friday at 5pm and Monday at 4am. Is there a DAX that can accomplish this?

2 ACCEPTED SOLUTIONS
techies
Super User
Super User

Hi @bmccaslin please check this

 

Create a calculated column

 

Sales_Weekend_Filter =
VAR SaleDateTime = Sheet2[DateTime]  
VAR SaleDay = WEEKDAY(SaleDateTime, 2)
VAR SaleTime = TIME(HOUR(SaleDateTime), MINUTE(SaleDateTime), SECOND(SaleDateTime))

RETURN
    IF(
        (SaleDay = 5 && SaleTime >= TIME(17, 0, 0)) ||
        (SaleDay = 6) ||
        (SaleDay = 7) ||
        (SaleDay = 1 && SaleTime <= TIME(4, 0, 0)),
        "Exclude",
        "Include"
    )
 
and the measure 
 
Filtered_Sales =
CALCULATE(
    SUM(Sheet2[Sales Amount]),
    Sheet2[Sales_Weekend_Filter] = "Include"
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

View solution in original post

v-kpoloju-msft
Community Support
Community Support

Hi @bmccaslin,
Thank you for reaching out to the Microsoft fabric community forum. Thank you @techies, for your inputs on this issue.

Calculated Column:

IsWeekendSalesWindow =

VAR WeekdayNumber = WEEKDAY(Sales[SalesDateTime], 2)  -- Monday=1, Sunday=7

VAR TimeOnly = TIME(HOUR(Sales[SalesDateTime]), MINUTE(Sales[SalesDateTime]), SECOND(Sales[SalesDateTime]))

RETURN

    SWITCH(TRUE(),

        -- Friday after 5 PM

        WeekdayNumber = 5 && TimeOnly >= TIME(17,0,0), TRUE,

        -- Saturday anytime

        WeekdayNumber = 6, TRUE,

        -- Sunday anytime

        WeekdayNumber = 7, TRUE,

        -- Monday before 4 AM

        WeekdayNumber = 1 && TimeOnly < TIME(4,0,0), TRUE,

        FALSE

    )

Dax Measure:

SalesOutsideWeekendWindow =
CALCULATE(
SUM(Sales[SalesAmount]),
FILTER(
Sales,
NOT (
VAR WeekdayNumber = WEEKDAY(Sales[SalesDateTime], 2)
VAR TimeOnly = TIME(HOUR(Sales[SalesDateTime]), MINUTE(Sales[SalesDateTime]), SECOND(Sales[SalesDateTime]))
RETURN
SWITCH(TRUE(),
WeekdayNumber = 5 && TimeOnly >= TIME(17,0,0),
TRUE(),
WeekdayNumber = 6,
TRUE(),
WeekdayNumber = 7,
TRUE(),
WeekdayNumber = 1 && TimeOnly < TIME(4,0,0),
TRUE(),
FALSE()
)
)
)
)

If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.

Thank you for using Microsoft Community Forum.

View solution in original post

5 REPLIES 5
v-kpoloju-msft
Community Support
Community Support

Hi @bmccaslin,
Thank you for reaching out to the Microsoft fabric community forum. Thank you @techies, for your inputs on this issue.

Calculated Column:

IsWeekendSalesWindow =

VAR WeekdayNumber = WEEKDAY(Sales[SalesDateTime], 2)  -- Monday=1, Sunday=7

VAR TimeOnly = TIME(HOUR(Sales[SalesDateTime]), MINUTE(Sales[SalesDateTime]), SECOND(Sales[SalesDateTime]))

RETURN

    SWITCH(TRUE(),

        -- Friday after 5 PM

        WeekdayNumber = 5 && TimeOnly >= TIME(17,0,0), TRUE,

        -- Saturday anytime

        WeekdayNumber = 6, TRUE,

        -- Sunday anytime

        WeekdayNumber = 7, TRUE,

        -- Monday before 4 AM

        WeekdayNumber = 1 && TimeOnly < TIME(4,0,0), TRUE,

        FALSE

    )

Dax Measure:

SalesOutsideWeekendWindow =
CALCULATE(
SUM(Sales[SalesAmount]),
FILTER(
Sales,
NOT (
VAR WeekdayNumber = WEEKDAY(Sales[SalesDateTime], 2)
VAR TimeOnly = TIME(HOUR(Sales[SalesDateTime]), MINUTE(Sales[SalesDateTime]), SECOND(Sales[SalesDateTime]))
RETURN
SWITCH(TRUE(),
WeekdayNumber = 5 && TimeOnly >= TIME(17,0,0),
TRUE(),
WeekdayNumber = 6,
TRUE(),
WeekdayNumber = 7,
TRUE(),
WeekdayNumber = 1 && TimeOnly < TIME(4,0,0),
TRUE(),
FALSE()
)
)
)
)

If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.

Thank you for using Microsoft Community Forum.

Hi @bmccaslin,

 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

 

Thank you.

Hi @bmccaslin,


I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

Hi @bmccaslin,


I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.


Thank you.

techies
Super User
Super User

Hi @bmccaslin please check this

 

Create a calculated column

 

Sales_Weekend_Filter =
VAR SaleDateTime = Sheet2[DateTime]  
VAR SaleDay = WEEKDAY(SaleDateTime, 2)
VAR SaleTime = TIME(HOUR(SaleDateTime), MINUTE(SaleDateTime), SECOND(SaleDateTime))

RETURN
    IF(
        (SaleDay = 5 && SaleTime >= TIME(17, 0, 0)) ||
        (SaleDay = 6) ||
        (SaleDay = 7) ||
        (SaleDay = 1 && SaleTime <= TIME(4, 0, 0)),
        "Exclude",
        "Include"
    )
 
and the measure 
 
Filtered_Sales =
CALCULATE(
    SUM(Sheet2[Sales Amount]),
    Sheet2[Sales_Weekend_Filter] = "Include"
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.