Months in which sessions exceed average sessions for year

Ashish Mathur

New Member
Joined
Mar 10, 2013
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have financial years in the column area of my Pivot Table. The following calculated Field formula return the average number of sessions conducted in each financial year

=AVERAGEX(VALUES(Calendar1[MonthKey]),[Sessions conducted])

The result of this formula is correct - so no problem so far.

I now wish to compute the "Number of months (in each financial year) in which the sessions conducted exceeded the average number of session". I tried the following calculated Field formula but nothing is returned in the Pivot Table

=COUNTROWS(FILTER(SUMMARIZE(Feedback,Calendar1[FiscalYearKey],Calendar1[MonthKey],"Sessions_per_month",[Sessions conducted]),[sessions_per_month]>[Average sessions conducted]))

There is no error in the formula (as confirmed by the Check formula message) but no data is returned in the Pivot Table.

Please help.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I think DAX format is important to read the formula, at least to myself :)
This is your formula:
Code:
=
COUNTROWS ( 
    FILTER ( 
        SUMMARIZE ( 
            Feedback,
            Calendar1[FiscalYearKey],
            Calendar1[MonthKey],
            "Sessions_per_month",
            [Sessions conducted]
        ),
        [sessions_per_month] > [Average sessions conducted]
    )
)
In this case, the [Average sessions conducted] is evaluated in a context defined by the row returned by SUMMARIZE, and it corresponds to the average of just one month (so the value of the month itself).
If you want to calculate the average session conducted in a month of the year you are considering, you have to change the filter context for such a calculation in this way:
Code:
=
COUNTROWS ( 
    FILTER ( 
        SUMMARIZE ( 
            Feedback,
            Calendar1[FiscalYearKey],
            Calendar1[MonthKey],
            "Sessions_per_month",
            [Sessions conducted]
        ),
        [sessions_per_month] 
        > CALCULATE ( 
              [Average sessions conducted],
              ALL( Calendar1[MonthKey] )
          )
    )
)
Let me know if it works for your scenario.
Marco
 
Upvote 0
Hi,

That worked very well. Thank you for your help. In future, will keep in mind to indent the formula for ease of reading.
 
Upvote 0

Forum statistics

Threads
1,223,939
Messages
6,175,529
Members
452,651
Latest member
wordsearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top