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
MPetramalo214
Helper I
Helper I

Loop Through Each Row of a Table to Determine If They Showed Up Again

I'm trying to come up with something to track the amount (or percentage) of "recurring" customers.

What I want to do, is check through a table of reservations that occured, and determine 

1) How many unique customers had reservations

2) How many of these customers, also had a reservation in the 90 days prior to their start date.

 

Example: 

MPetramalo214_1-1636397673286.png

I know how to get the count of the 8 distinct customers in the list shown above, but I'm stumped on how to loop through the table again to see if they had a different reservation no more than 90 days prior. 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@MPetramalo214 Maybe:

 

Measure = 
  VAR __Table = 
    ADDCOLUMNS(
      ADDCOLUMNS(
        SUMMARIZE(
          'Table',
          [Owner Id],
          "__LastDate",MAX([Check-In Date])
        ),
        "__PreviousDate",MAXX(FILTER(ALL('Table'),[Check-In Date]<[__LastDate] && [Owner Id]=EARLIER([Owner Id]),[Check-In Date])
      ),
    "__Diff",([__LastDate] - [__PreviousDate]) * 1.
  )
RETURN
  COUNTROWS(FILTER(__Table,[__Diff]<90))

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@MPetramalo214 Maybe:

 

Measure = 
  VAR __Table = 
    ADDCOLUMNS(
      ADDCOLUMNS(
        SUMMARIZE(
          'Table',
          [Owner Id],
          "__LastDate",MAX([Check-In Date])
        ),
        "__PreviousDate",MAXX(FILTER(ALL('Table'),[Check-In Date]<[__LastDate] && [Owner Id]=EARLIER([Owner Id]),[Check-In Date])
      ),
    "__Diff",([__LastDate] - [__PreviousDate]) * 1.
  )
RETURN
  COUNTROWS(FILTER(__Table,[__Diff]<90))

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors