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

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

3 REPLIES 3
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] ) )
    )
)

Regards
Zubair

Please try my custom visuals
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!!!

 

 

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