How to workaround Calculate function ignoring filter context
I have 2 measures. The first one simply counts all orders and the 2nd one does the same thing but for a specific date.
This works fine however if I want to group the second measure by sales agent I get the same value for each agent, which is of course wrong. I need the number filtered by sales agent. I've googled and searched these forums but I cant find anything specific to working around this issue. My measure uses calculate so I'm hoping it is a simple substituion for another function but I can't find one that works. Here are my measures.
Measure 1: AllOrders = COUNTROWS('Orders')
Measure 2: OrdersPrevDay = VAR PDate = LASTDATE('Calendar'[Date])