Forum Discussion

Cyriackpazhe's avatar
Cyriackpazhe
Helper III
1 year ago
Solved

iterator

I dont understand the values at month level. Shouldn't it display the same values as the years since ALL is used in the measure. Could someone explain.  
  • bhanu_gautam's avatar
    1 year ago

    Cyriackpazhe 

    The confusion arises from the use of the ALL function in your DAX measure. The ALL function removes all filters from the specified column or table, which can lead to unexpected results if not used correctly.

    Your measure is defined as:

    AVERAGEX(ALL('Calendar'[Date].[Year], 'Calendar'[Date].[Month]), [Total])


    This measure calculates the average of [Total] over all years and months, ignoring any filters applied to the Year and Month columns. This means that the measure will compute the average of [Total] across the entire dataset, not just for the specific year or month in the current context.

     

    If you want the measure to display the same values at the month level as it does at the year level, you need to ensure that the measure respects the current context of the year and month. You might want to use a different approach that maintains the context of the year and month. For example, you could use the CALCULATE function to modify the filter context:

     

    AVERAGEX(
    CALCULATETABLE(
    VALUES('Calendar'[Date]),
    ALL('Calendar'[Date].[Year])
    ),
    [Total]
    )
    This measure calculates the average of [Total] for each month within the context of the current year, rather than removing the filters entirely. This way, the measure will respect the current year context while still calculating the average for each month.