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

Calculating Avg # Activities Per Day/Week/Month

I am trying to calculate the average number of activities per day / week / month. Current data has an activities column [actv_id]. The below syntax worked fine for calculating the average per day. 

 

 

Avg # of Activities Per Day =
AVERAGEX(
CALCULATETABLE('Customer Support Activity - CSR', 'Customer Support Activity - CSR'[ToDate] <> BLANK() ),
VAR St = 'Customer Support Activity - CSR'[fr_date]
VAR En = 'Customer Support Activity - CSR'[ToDate]
RETURN
COUNTROWS(
CALCULATETABLE(
'Calendar',
'Calendar'[Date] >= St,
'Calendar'[Date] <= En
)
)
)

 

There are calculated columns for:

 

- ToDate = TODAY()

- Week = WEEKNUM('Customer Support Activity  - CSR'[fr_date])

- Month = FORMAT('Customer Support Activity  - CSR'[fr_date], "MMM yyyy")

 

Problem: I assumed that if I changed "VAR En" = [Week], it would work for week (same as if I was to change it month) but that did not work. 

 

Goal: I am trying to create a measure where I can calculate Avg # of Activities per Week + per Month. 

 

Any assistance on how I can make this work is greatly appreciated!

 

Thank you Datanauts!

 

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

Can you share a sample file, please? You can try a formula like below.

 

Measure =
AVERAGEX (
    SUMMARIZE (
        FactSales,
        DimDate[CalendarWeek],
        "#activities", COUNTROWS ( FactSales )
    ),
    [#activities]
)
    + AVERAGEX (
        SUMMARIZE (
            FactSales,
            DimDate[CalendarMonth],
            "#activities", COUNTROWS ( FactSales )
        ),
        [#activities]
    )

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

Can you share a sample file, please? You can try a formula like below.

 

Measure =
AVERAGEX (
    SUMMARIZE (
        FactSales,
        DimDate[CalendarWeek],
        "#activities", COUNTROWS ( FactSales )
    ),
    [#activities]
)
    + AVERAGEX (
        SUMMARIZE (
            FactSales,
            DimDate[CalendarMonth],
            "#activities", COUNTROWS ( FactSales )
        ),
        [#activities]
    )

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-jiascu-msft Thank you so much for your response. I am trying workup the syntax that you have provided. For reference, please see my active workbook. I am curious to know your thoughts on how to achieve the anticipated goal of calculating the average # of activities per week + average # of activities per month. 

 

Below is the link to my active workbook. 

 

I appreciate you and gratitude!

Anthony

 

https://github.com/anthonynguyen3/Power-BI/blob/master/Customer%20Support%20Activity%20-%20CSR%20BI....

Hi @Anonymous,

 

Please download the demo from here: https://1drv.ms/u/s!ArTqPk2pu-BkhBgYAX1_jsXde7IiPlease don't share sensitive data. 

I'm not 100 percent sure what the result should be. If it's the average value monthly, you just need one measure. If it's a value of the average of the values of months, there could be three measures. 

1. Create a new column due to the old relationship doesn't match any values.

DateForRelationship = [fr_date].[Date]  //delete the relationship first.

2. Create three measures, including one renewed measure.

Avg # of Activities Per Day New =
AVERAGEX (
    'Customer Support Activity  - CSR',
    DATEDIFF ( [fr_date], TODAY (), DAY )
)
Avg # of Activities Per Week New =
AVERAGEX (
    SUMMARIZE (
        'Customer Support Activity  - CSR',
        'Calendar'[Week],
        "WeeklyTotal", CALCULATE (
            SUMX (
                'Customer Support Activity  - CSR',
                DATEDIFF ( [fr_date], TODAY (), DAY )
            )
        )
    ),
    [WeeklyTotal]
)
Avg # of Activities Per Month =
AVERAGEX (
    SUMMARIZE (
        'Customer Support Activity  - CSR',
        'Calendar'[Month],
        "MonthlyTotal", CALCULATE (
            SUMX (
                'Customer Support Activity  - CSR',
                DATEDIFF ( [fr_date], TODAY (), DAY )
            )
        )
    ),
    [MonthlyTotal]
)

Calculating-Avg-Activities-Per-Day-Week-Month

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-jiascu-msft You my friend, are a hero!

 

So much gratitude! Thank you!

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.