Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dkb1898
Regular Visitor

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

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
0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.