Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
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?
Solved! Go to Solution.
Hi @bmccaslin please check this
Create a calculated column
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,
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.
Hi @bmccaslin please check this
Create a calculated column
User | Count |
---|---|
12 | |
12 | |
8 | |
8 | |
6 |
User | Count |
---|---|
27 | |
19 | |
13 | |
11 | |
7 |