Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 18030

Rolling Data that needs a probable sub-select to own table

$
0
0

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

 

DateClientNameClientDOBLast30DayCount
04/30/2016ClientName101/01/19701
05/10/2016ClientName101/01/19702
05/10/2016ClientName212/31/19741
05/26/2016ClientName101/01/19703
06/15/2016ClientName101/01/19702
06/15/2016ClientName212/31/19741

Viewing all articles
Browse latest Browse all 18030

Trending Articles