Forum Discussion
MarceloPereira
6 years agoFrequent Visitor
Exclude weekend using dateadd
Hi Everyone. I need help to compare the margin of sales. When I compare Monday's sales margin with the day before, the DATEADD function searches for Sunday's margin, where I don't have sales....
- 6 years ago
Hi MarceloPereira ,
Try this instead:C_MargemTeste = var _Date = MAX(DIM_CALENDARIO[Date]) var _isWeekday = WEEKDAY(_Date, 2) RETURN SWITCH(TRUE(), _isWeekday = 1, CALCULATE([C_Margem], DIM_CALENDARIO[Data] = _Date - 3), _isWeekday > 1 && _isWeekday <= 5, CALCULATE([C_Margem], DIM_CALENDARIO[Data] = _Date - 1))
hnguy71
6 years agoSuper User
Hi MarceloPereira ,
You need to adjust the measure. YOUR_TABLE needs to be replaced with whatever table name you're currently using with your date field. The same goes for your other fields. If the information is not sensitive, provide a PBIX and I can help you further.
MarceloPereira
6 years agoFrequent Visitor
- hnguy716 years agoSuper User
Hi MarceloPereira ,
Try this instead:C_MargemTeste = var _Date = MAX(DIM_CALENDARIO[Date]) var _isWeekday = WEEKDAY(_Date, 2) RETURN SWITCH(TRUE(), _isWeekday = 1, CALCULATE([C_Margem], DIM_CALENDARIO[Data] = _Date - 3), _isWeekday > 1 && _isWeekday <= 5, CALCULATE([C_Margem], DIM_CALENDARIO[Data] = _Date - 1))- MarceloPereira6 years agoFrequent Visitor
- Jwheels276 years agoNew Member
How would you account for holidays using this?