DAX Iterative table averaging based on dynamic overlapping data based on slicer selection
23:25 25 Mar 2026

I have two stand-alone tables:

'Data' with columns [Label] text, [Year] integer, [Location] text, [Value] integer.

'Label_List' with column [Label] text. (list of distinct [Label] column seen in 'Data' table.)

In 'Data' table, each [Label] can have data for multiple years and multiple locations.

I have a user selected value for 'Label_List'[Label] from a slicer.

In the visualization I am trying to compare each [Label] (row) to the slicer selected [Label]. I am struggling to calculate and display the [Value] average for each [Label] row by row, with using only the specific subset of [Value] values that have overlapping combinations of [Year] and [Location] with the slicer selected [Label]. This is the "Label Average Overlap" in the Visualization example table.

I have had success with writing the code for the other overlap column. For example:

Selected Label Average Overlap = 
CALCULATE(
    AVERAGE(Data[Value]),
    Data[Label] = SELECTEDVALUE(Label_List[Label]),
    Data[Year] IN VALUES(Data[Year]) && Data[Location] IN VALUES(Data[Location])
)

I have struggled with writing the code for the "Label Average Overlap"

Label Average Overlap = 

VAR SlicerLabel = SELECTEDVALUE(Label_List[Label])
VAR DataLabelRow = SELECTEDVALUE(Data[Label]) 

VAR CommonYearsAndLocations =
    CALCULATETABLE(
        VALUES(Data[Year]),
        FILTER(
            Data,
            COUNTROWS(
                FILTER(Data, Data[Year] = EARLIER(Data[Year]) && Data[Location] = EARLIER(Data[Location]) && Data[Label] = DataLabelRow)
            ) > 0 &&
            COUNTROWS(
                FILTER(Data, Data[Year] = EARLIER(Data[Year]) && Data[Location] = EARLIER(Data[Location]) && Data[Parent] = SlicerLabel)
            ) > 0
        )
    )

RETURN
    CALCULATE(
        AVERAGE(Data[Value]),
        Data[Label] = SlicerLabel,
        Data[Year] IN CommonYearsAndLocations,
        Data[Location] IN VALUES(Data[Location]) 
    )

'Label_List' Table

Label
A
B
C
D
E
F

'Data' Table

Label Year Location Value
A 2022 LocationA 100
A 2023 LocationA 103
A 2024 LocationA 105
A 2024 LocationB 95
A 2025 LocationA 110
B 2021 LocationB 90
B 2023 LocationB 91
B 2024 LocationA 92
B 2025 LocationA 94
B 2025 LocationB 93
C 2021 LocationA 87
C 2023 LocationB 89
C 2024 LocationA 85
D 2021 LocationA 100
D 2022 LocationA 100
D 2023 LocationA 104
E 2023 LocationB 110
E 2024 LocationB 112
E 2025 LocationB 109
F 2021 LocationA 99
F 2022 LocationA 98
F 2022 LocationB 95
F 2023 LocationA 97
F 2024 LocationB 98

Table Visualization: Example where Label A is selected in the slicer. All values compare to Label A.

Label Label Average Label Average Overlap Selected Label Average Selected Label Average Overlap
A 102.6 102.6 102.6 102.6
B 92 93 102.6 107.5
C 87 85 102.6 105
D 101.33 102 102.6 101.5
E 110.33 112 102.6 95
F 97.4 97.67 102.6 99.33
powerbi dax