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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.