I have a unique situation that I'm used to handling in SQL, but I'm unsure how to deal with it in Power BI. I need a hit count on when a user appears in a table within the last 30 days for each line item. So it's not a grouping thing, and I'm not sure Calculate will work. I also have to join on the ClientName, ClientDOB, and another status field as it's the only unique identifier I have for the client and the true hit count I need.
Again I know how I would do a subselect on that same table in SQL, just not sure how I'd it in PowerBI. The SQL would look as so
SELECT
Date,
ClientName,
ClientDOB,
(
SELECT COUNT(*)
FROM MyTable
WHERE ClientName = MT.ClientName
AND ClientDOB = MT.ClientDOB
AND Date BETWEEN DATEADD(MT.Date, -30, Day) and MT.Date
) AS Last30DayCount
FROM MyTable MT
Date | ClientName | ClientDOB | Last30DayCount |
04/30/2016 | ClientName1 | 01/01/1970 | 1 |
05/10/2016 | ClientName1 | 01/01/1970 | 2 |
05/10/2016 | ClientName2 | 12/31/1974 | 1 |
05/26/2016 | ClientName1 | 01/01/1970 | 3 |
06/15/2016 | ClientName1 | 01/01/1970 | 2 |
06/15/2016 | ClientName2 | 12/31/1974 | 1 |