How to write code for the MODE function in Powerpivot?

lmgarzio

New Member
Joined
Jul 10, 2013
Messages
1
Hello, I am baffled by the fact that MODE is not a recognized function in Powerpivot. Can someone help me write code for the MODE function so that it can be calculated in Powerpivot as a Calculated Field?

Thank you!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I think you would probably need 2 Calculated Columns to get this:

1. To count recurrence
2. Find the max of 1.

Code:
TableName[ColumnCnt]=CALCULATE(
                                         COUNT([ColumnName]),
                                         FILTER(TableName,
                                               TableName[ColumnName] = EARLIER(TableName[ColumnName])
                                          )
                                      )

Code:
TableName[Mode]=MAX([ColumnCnt])=[ColumnCnt]

The TRUE in TableName[Mode] is your answer.
 
Upvote 0
This thread is a little old but I was revisiting it for another PowerPivot problem that needs to show the MODE. I needed a dynamic version that was done with a measure and not a calculated column. Looks like this is what the OP was asking for the first time but I misunderstood.

Anyway, thought I would update this with the Measure/Calc Field version that I am using to identify the MODE in case it could help others:

Code:
=IF(
      CALCULATE(
              MAXX(
                     VALUES(TableName[Data]),
                            CALCULATE(
                                     COUNTROWS(TableName)
                             )
                     ),
               ALLSELECTED(TableName)
      )
      = COUNTROWS(TableName),
      "MODE",
      BLANK()
 )

With my data set in Pivot Rows, this is working well for me and changes dynamically with slicer selections.
 
Upvote 0

Forum statistics

Threads
1,223,970
Messages
6,175,693
Members
452,667
Latest member
vanessavalentino83

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