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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

CALCULATE Context

Hi community,

 

I have a problem with understanding why a formula in DAX works. It is a question around CALCULATE and about how to change the FILTER CONTEXT. I got it to work at the end but I cannot understand why it is working. The Power BI file is on my GitHub and I share the link.


The Domain

I have one table in Power BI that contains the following information:

museum_visitors( Date, Month, Year, Museum, Visitors )

 

Data are monthly, so I have 1 entry for each month from 2015 to 2018. I am trying to calculate a seasonality index in this way:

 

Average Visit by month / Average Visit overall

 

I want to display the seasonality index in a table that contains the month name. I place a slicer with the names of the different museums in my report.

 

Then I create the measure Avg Visitors := AVERAGE( museum_visitors[Visitors] )

This measure, when placed in a table with the Month correctly gives me the average of the different months.

 

Now I have some problem with the overall average. In fact, since the measure needs to work in this table, I understand that I need to use CALCULATE to get rid of the month name that is present in the filter context and calculates the overall average so I write this measure:

 

Avg Overall := CALCULATE(
                                   AVERAGE(    museum_visitors[Visitors] ),
                                   ALL( museum_visitors[Date] )
                         )

I would expect that when I drag the measure in the table I obtain one column with equal values that is the overall average but I have the very same result of Avg Visitors. I tried to change the second condition in this way ALL( museum_visitors[Month] ) but it did not work and I also tried to make explicit the second condition writing:

 

Avg Overall := CALCULATE(
                                    AVERAGE( museum_visitors[Visitors] ),
                                    FILTER(
                                           museum_visitors,
                                           ALL( museum_visitors[Date] )
                                    )            
                          )

 

The above resulted in an error. Why?

I achieved this doing the following:

Seasonality Index = AverageVisitors_CurrentMonth / OverallAverage
AverageVisitors_Jan = (Visitors_Jan2015 + Visitors_Jan2016 + Visitors_Jan2017) / 3

The way I solved my problem

Finall I solved my problem using:

SeasonalityIndex := [AverageVisitors] / [Avg Overall]

Avg Overall := CALCULATE(
                                AVERAGE( museum_visitors[Visitors] ),
                                ALLSELECTED()
                       )

 

My question
I don't understand why the formula above works. Could someone explain this to me?

 

Link to my Git Hub where is the file

For reference my Power BI file is on my GitHub:  
https://github.com/ellenne/PowerBI/tree/master/10.%20Out

1 REPLY 1
parry2k
Super User
Super User

@Anonymous gone thru your post and seem like in the end you are asking why ALLSELECTED works, correct?

 

Let me ask you why you think it is working? Did you read about ALLSELECTED function here?

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.