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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Calculate event count per month-year and operator

Dear all,

 

  I'm trying to create a calculated column ('Event_Count') that would sum up all "1" of column "Event" based on the month-year and on the operator. For example, below is January 2017 data. The sum of the "1" in Event is 2 for January 2017 and Operator A. The column 'Event_Month' should just count the total for the matching month-year and opeator at every cell. Does anyone know how to do it?

 

DateEventOperatorEvent_Count
1-Jan-170  
2-Jan-170  
3-Jan-170  
4-Jan-170  
5-Jan-171A2
6-Jan-170  
7-Jan-170  
8-Jan-170  
9-Jan-171B4
10-Jan-170  
11-Jan-170  
12-Jan-171A2
13-Jan-170  
14-Jan-170  
15-Jan-171B4
16-Jan-170  
17-Jan-170  
18-Jan-170  
19-Jan-171B4
20-Jan-171C2
21-Jan-170  
22-Jan-170  
23-Jan-170  
24-Jan-171C2
25-Jan-170  
26-Jan-170  
27-Jan-170  
28-Jan-170  
29-Jan-170  
30-Jan-171B4
31-Jan-170  

 

Thank you.

1 ACCEPTED SOLUTION

Hi @Anonymous

 

Try this Calculated Column

 

EventCount =
COUNTROWS (
    FILTER (
        TableName,
        TableName[Operator] = EARLIER ( TableName[Operator] )
            && TableName[Event] = 1
            && MONTH ( TableName[Date] ) = MONTH ( EARLIER ( TableName[Date] ) )
            && YEAR ( TableName[Date] ) = YEAR ( EARLIER ( TableName[Date] ) )
    )
)

View solution in original post

4 REPLIES 4
BeemsC
Resolver III
Resolver III

Does it need to be in 1 column? And are you allowed to use measures?

Anonymous
Not applicable

@BeemsC unfortunately it has to be a calculated column...

Hi @Anonymous

 

Try this Calculated Column

 

EventCount =
COUNTROWS (
    FILTER (
        TableName,
        TableName[Operator] = EARLIER ( TableName[Operator] )
            && TableName[Event] = 1
            && MONTH ( TableName[Date] ) = MONTH ( EARLIER ( TableName[Date] ) )
            && YEAR ( TableName[Date] ) = YEAR ( EARLIER ( TableName[Date] ) )
    )
)
Anonymous
Not applicable

@Zubair_Muhammad Thanks! It works.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.