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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
StrikerZero
Frequent Visitor

Quantity of occurrences in a time interval

I am trying to calculate the number of occurrences of the same event and product in the last 7 days. Below is a table to illustrate:

 

IDPRODUCTEVENTDATEOCCURRENCES IN LAST 7 DAYS
1A120/10/20202 (ID 1 and 3)
2A217/10/2020
3A114/10/20202 (ID 3 and 4)
4A111/10/20201
5B118/10/20201
6B316/10/20202 (ID 6 and 7)
7B315/10/20201
8C318/10/20201

 

I've tried several measures, but I'm not having success. can anybody help me?

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

@StrikerZero  this code might be what you want

OCCURRENCES IN LAST 7 DAYS:=CALCULATE(COUNT(EventsTable[EVENT]),DATESINPERIOD(EventsTable[DATE],MAX(EventsTable[DATE]),-7,DAY),ALLEXCEPT(EventsTable,EventsTable[PRODUCT],EventsTable[EVENT]))

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@StrikerZero  you can try this formula .

test =
CALCULATE(COUNTROWS(data_Tables),DATEADD(data_Tables[Date],-7,DAY))
 
can you share a sample pbix file
wdx223_Daniel
Super User
Super User

@StrikerZero  this code might be what you want

OCCURRENCES IN LAST 7 DAYS:=CALCULATE(COUNT(EventsTable[EVENT]),DATESINPERIOD(EventsTable[DATE],MAX(EventsTable[DATE]),-7,DAY),ALLEXCEPT(EventsTable,EventsTable[PRODUCT],EventsTable[EVENT]))

 

The @wdx223_Daniel solution is perfect.
Sorry for the delay in responding, I had to make an emergency trip.
Before marking the answer to the end of the topic, could you show me how to drill through or filter these items from the occurrence? For example, if it is shown that an event had 3 occurrences, what were those occurrences?

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors