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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
stribor45
Post Prodigy
Post Prodigy

how to calculate Average from columns from different tables

I have two tables and each of them holds the data from different years (2023 and 2024).  I would like to create a measure that would calculate the average of column A from each table. so for example, if Table A is for 2023, Table B is for 2024 I can do the following:

 

(AVERAGE(TABLE_A[A]) +  AVERAGE(TABLE_B[A])) / 2

 

problem with this is that sometimes users might select dates that don't spill into other tables which skews the results. Say if my calculated average for July 2023 is 12 this formula would give me a result of 6 instead of 12. 

 

Any suggestions?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @stribor45 

 

Thanks for the reply from aduguid .

 

My sample:

 

Slicer table:

vxuxinyimsft_0-1724060885975.png

 

TableA:

vxuxinyimsft_1-1724060918781.png

 

TableB:

vxuxinyimsft_3-1724061112411.png

 

Create a measure as follows

Measure = 
VAR _1 = CALCULATE(MAX('TableA'[A]), FILTER(TableA, [Date] = SELECTEDVALUE(Slicer[Date])))
VAR _2 = CALCULATE(MAX('TableB'[A]), FILTER(TableB, [Date] = SELECTEDVALUE(Slicer[Date])))
RETURN
IF(_1 = BLANK() || _2 = BLANK(), (_1 + _2) / 1, (_1 + _2) / 2)

 

Output:

vxuxinyimsft_4-1724061144342.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @stribor45 

 

Thanks for the reply from aduguid .

 

My sample:

 

Slicer table:

vxuxinyimsft_0-1724060885975.png

 

TableA:

vxuxinyimsft_1-1724060918781.png

 

TableB:

vxuxinyimsft_3-1724061112411.png

 

Create a measure as follows

Measure = 
VAR _1 = CALCULATE(MAX('TableA'[A]), FILTER(TableA, [Date] = SELECTEDVALUE(Slicer[Date])))
VAR _2 = CALCULATE(MAX('TableB'[A]), FILTER(TableB, [Date] = SELECTEDVALUE(Slicer[Date])))
RETURN
IF(_1 = BLANK() || _2 = BLANK(), (_1 + _2) / 1, (_1 + _2) / 2)

 

Output:

vxuxinyimsft_4-1724061144342.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

aduguid
Super User
Super User

I'd use power query and append the tables to get it into one recordset. 

Yes i was hoping to use DAX

Try this measure 

Combined Average = 
VAR AvgA_2023 = 
    CALCULATE(
        AVERAGE(Table_A[A]),
        NOT(ISBLANK(Table_A[A]))
    )
VAR AvgA_2024 = 
    CALCULATE(
        AVERAGE(Table_B[A]),
        NOT(ISBLANK(Table_B[A]))
    )
VAR CountTableA = 
    CALCULATE(
        COUNTROWS(Table_A),
        NOT(ISBLANK(Table_A[A]))
    )
VAR CountTableB = 
    CALCULATE(
        COUNTROWS(Table_B),
        NOT(ISBLANK(Table_B[A]))
    )
VAR TotalRows = CountTableA + CountTableB

RETURN
    IF(
        TotalRows = 0,
        BLANK(),
        (IF(CountTableA > 0, AvgA_2023, 0) + IF(CountTableB > 0, AvgA_2024, 0)) / 
        (IF(CountTableA > 0, 1, 0) + IF(CountTableB > 0, 1, 0))
    )

I am getting 0 as a result

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.