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
Anonymous
Not applicable

Mesure for finding occurrence 7 times in 7 consecutive days

I have a query I tried to resolve but I failed badly. I have a table below:

 
 
DateLinkName
15/08A
16/08A
17/08A
18/08A
19/08A
20/08A
21/08A
15/08B
16/08B
17/08B
18/08B
19/08B
20/08B
21/08B
22/08A
23/08B
24/08B
25/08A
26/08A
27/08A

 

and how i get a result like this 

 

Datefind occurrence 7 times in 7 consecutive days
15/080
16/080
17/080
18/080
19/080
20/080
21/082
22/080
23/080
24/080
25/080
26/080
27/080

 

I can get this problem in excel,  but it is hard for me to do it in PowerBi. Iam trying my best to learn PowerBi. Hopefully anyone can help me solve this problem. 

 

 

 

 

1 ACCEPTED SOLUTION

@Anonymous - Sorry, I made this more complicated than necessary. See Table (25) of attached PBIX below sig.

Column = 
  VAR __Table = FILTER('Table (25)',[LinkName]=EARLIER([LinkName]) && [Date]<=EARLIER([Date]) && [Date]>=EARLIER([Date])-7)
RETURN
  IF(COUNTROWS(__Table)=7,1,0)

 


@ 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

6 REPLIES 6
Greg_Deckler
Super User
Super User

@Anonymous - Perhaps:

 

Column =
  VAR __Table = SUMMARIZE(FILTER('Table',[LinkName]=EARLIER([LinkName]) && [Date]<=EARLIER([Date]) && [Date]>=EARLIER([Date])-7),[LinkName])
RETURN
  IF(COUNTROWS(__Table)=7,1,0)

 


@ 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...
Anonymous
Not applicable

@Anonymous - Sorry, I made this more complicated than necessary. See Table (25) of attached PBIX below sig.

Column = 
  VAR __Table = FILTER('Table (25)',[LinkName]=EARLIER([LinkName]) && [Date]<=EARLIER([Date]) && [Date]>=EARLIER([Date])-7)
RETURN
  IF(COUNTROWS(__Table)=7,1,0)

 


@ 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...
Anonymous
Not applicable

@Greg_Deckler yeah, U got it. I still have question, U used calculated collumn to solve this, but my table is very large ( ~ 500000 rows ). So Could we use Mesure instead of Calculated collumn. 

 

 

@Anonymous - You could, that would look like this:

Column = 
  VAR __Link=MAX([LinkName])
  VAR __Date=MAX([Date])
  VAR __Table = FILTER('Table (25)',[LinkName]=__Link && [Date]<=__Date && [Date]>=__Date-7)
RETURN
  IF(COUNTROWS(__Table)=7,1,0)

Would have to do some additional experimenting to get it to aggregate by Date (so you have just date in your visual and you want 2 to appear for A and B consequetive runs. This assumes you have LinkName in the visual. But, all that said, I *think* you will be happier with a column. This is because it runs a single time during data load. Otherwise, your measure will have to constantly recaculate while you are browing the report and that will be slooooooowwww!! 🙂 


@ 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...
Anonymous
Not applicable

It returns 0 for all rows. Maybe sth wrong.

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