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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Counting number of occurrences in a month

Hello, I have the following dataset in Power BI and I'm interested in adding a column to see how many times a client visited in a calendar month. 

 

Data:

Client_IDDateMonth
0011/5/20142014/1
0021/6/20142014/1
0031/7/20142014/1
0041/8/20142014/1
0051/10/20142014/1
0061/11/20142014/1
0071/12/20142014/1
0081/13/20142014/1
0011/15/20142014/1
0021/17/20142014/1
0041/20/20142014/1
0061/21/20142014/1
0011/21/20142014/1
0021/22/20142014/1
0061/23/20142014/1
0022/1/20142014/2
0012/3/20142014/2
0032/4/20142014/2

 

Wanted Result:

Client_IDDateMonthN Visits that month
0011/5/20142014/13
0021/6/20142014/13
0031/7/20142014/11
0041/8/20142014/12
0051/10/20142014/11
0061/11/20142014/13
0071/12/20142014/11
0081/13/20142014/11
0011/15/20142014/13
0021/17/20142014/13
0041/20/20142014/12
0061/21/20142014/13
0011/21/20142014/13
0021/22/20142014/13
0061/23/20142014/13
0022/1/20142014/21
0012/3/20142014/21
0032/4/20142014/21

 

Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I got an error on your column, but I figured it out. Here is the column I created:

 

Monthly Visits =

CALCULATE(

    COUNT(Congregate_Only_Logs[Client_ID]),

    FILTER(Congregate_Only_Logs,

    Congregate_Only_Logs[Month]=EARLIER(Congregate_Only_Logs[Month])),

    FILTER(Congregate_Only_Logs,

        Congregate_Only_Logs[Client_ID]=EARLIER(Congregate_Only_Logs[Client_ID])))

 

Thanks!!!

 

 

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

HI @Anonymous

 

Try this column

 

N Visits =
CALCULATE (
    COUNT ( TableName[Date] ),
    FILTER (
        ALLEXCEPT ( TableName, TableName[Client_ID] ),
        MONTH ( TableName[Date] ) = MONTH ( EARLIER ( TableName[Date] ) )
    )
)
Anonymous
Not applicable

Hi @Zubair_Muhammad 

In the same example, how can we calculate the visit in the last X days? 

Could you help with that please? 

Thank you 

Ilky

Anonymous
Not applicable

I got an error on your column, but I figured it out. Here is the column I created:

 

Monthly Visits =

CALCULATE(

    COUNT(Congregate_Only_Logs[Client_ID]),

    FILTER(Congregate_Only_Logs,

    Congregate_Only_Logs[Month]=EARLIER(Congregate_Only_Logs[Month])),

    FILTER(Congregate_Only_Logs,

        Congregate_Only_Logs[Client_ID]=EARLIER(Congregate_Only_Logs[Client_ID])))

 

Thanks!!!

 

 

Hi @Zubair_Muhammad 

 

This formula worked for me to capture the number of occurrence of a particular value, by month.

But I have the data since 2021. So this formula has seggregated the number of occurrences of a value in each month, for all the years. For example, Number of occurrences of the value in July, for 2021,2022,2023 and 2024. But what i'm looking for here is, number of occurrences of a value in July 2021, July 2022, July 2023 and July 2024.

 

Can you help me build a formula, where we can separate the years and months?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors