Forum Discussion
Exclude weekend using dateadd
- 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))
Try if Earlier can work in this case
https://community.powerbi.com/t5/Desktop/Explanation-of-the-EARLIER-formula/td-p/529469
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.
My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
- MarceloPereira6 years agoFrequent Visitor
Hi amitchandak,.
I can't see how this function could help me in this case. What did you think?
regards
- hnguy716 years agoSuper User
Hi MarceloPereira ,
Try this as a measure:
PreviousMargin = var _Date = MAX(YOUR_TABLE[Date]) var _isWeekday = WEEKDAY(_Date, 2) RETURN SWITCH(TRUE(), _isWeekday = 1, CALCULATE(MAX(YOUR_TABLE[Margins]), YOUR_TABLE[Date] = _Date - 3), _isWeekday > 1 && _isWeekday <= 5, CALCULATE(MAX(YOUR_TABLE[Margins]), YOUR_TABLE[Date]= _Date - 1))- MarceloPereira6 years agoFrequent Visitor
Hi hnguy71 ,
I understand your logic, but my table has other dimensions that should be taken into account at this point in the calculation.
Because of this, I am receiving the following message:
The MAX function only accepts a column reference as the argument number 1.regards,