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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Average of columns of related and main tables ignoring pivot rows

Hi

 

I have two tables which are related to each other. Have created a pivot data model. I'm trying to get the average of one of the columns from the related table and the current table in a single pivot. The average should be based on a slicer rather than individual rows of the pivot table. I have tried to capture my thoughts in the Sample Excel.

 

My aim is to get all the columns in green in a single pivot which should seamlessly work with the provided slicer.

 

Please help me.

 

Thanks

Guru

2 ACCEPTED SOLUTIONS
selimovd
Super User
Super User

Hey @Anonymous ,

 

I think I found a solution.

First of all you have to use the slicer from the dimensional table, so from Range[CAT_PRIMARY_KEY] and not from 'Range 1'[CAT_FOREIGN_KEY] as the table Range is filtering Range 1 and not the other way around.

 

Once you did that these are the measures:

Average Range Value :=
CALCULATE(
    AVERAGE( Range[Value] );
    ALLSELECTED( Range[CAT_PRIMARY_KEY] )
)

 

And the spread:

Average Spread :=
CALCULATE(
    AVERAGE( 'Range 1'[Spread] );
    ALLSELECTED( Range[CAT_PRIMARY_KEY] );
    ALL( 'Range 1'[Part] )
)

 

Then Measure1 is just an easy calculation:

Measure1 := SUM( 'Range 1'[Spread] ) * [Average Range Value]

 

As well as Measure2:

Measure2 := SUM( 'Range 1'[Spread] ) * [Average Spread]

 

The result looks then identical:

selimovd_0-1623919576908.png

 

My solution you will find here:

https://www.swisstransfer.com/d/43aa970d-2670-462b-bb6d-bf4fed3a85fd

 

I hope I could help a Guru 😉

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

Hey @Anonymous ,

 

I'm happy I could help you and thanks for the compliment, haha 😊

OK, got it, replace the [Average Spread] measure with the following one:

Average Spread :=
CALCULATE(
    AVERAGE( 'Range 1'[Spread] );
    ALLSELECTED( Range[CAT_PRIMARY_KEY] );
    ALL(
        'Range 1'[CAT_FOREIGN_KEY];
        'Range 1'[Part]
    )
)

 

That should work.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

6 REPLIES 6
selimovd
Super User
Super User

Hey @Anonymous ,

 

I think I found a solution.

First of all you have to use the slicer from the dimensional table, so from Range[CAT_PRIMARY_KEY] and not from 'Range 1'[CAT_FOREIGN_KEY] as the table Range is filtering Range 1 and not the other way around.

 

Once you did that these are the measures:

Average Range Value :=
CALCULATE(
    AVERAGE( Range[Value] );
    ALLSELECTED( Range[CAT_PRIMARY_KEY] )
)

 

And the spread:

Average Spread :=
CALCULATE(
    AVERAGE( 'Range 1'[Spread] );
    ALLSELECTED( Range[CAT_PRIMARY_KEY] );
    ALL( 'Range 1'[Part] )
)

 

Then Measure1 is just an easy calculation:

Measure1 := SUM( 'Range 1'[Spread] ) * [Average Range Value]

 

As well as Measure2:

Measure2 := SUM( 'Range 1'[Spread] ) * [Average Spread]

 

The result looks then identical:

selimovd_0-1623919576908.png

 

My solution you will find here:

https://www.swisstransfer.com/d/43aa970d-2670-462b-bb6d-bf4fed3a85fd

 

I hope I could help a Guru 😉

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

Thanks a lot @selimovd. You don't know how much you have helped me. I've been struggling with this one from past 5hrs. Average value worked very well but the average spread should also be similar to average value i.e rather than broken down by the category it should be the average spread of all selected categories.

By the way I'm just a namesake Guru. You are the real 'Guru'.

Hey @Anonymous ,

 

I'm happy I could help you and thanks for the compliment, haha 😊

OK, got it, replace the [Average Spread] measure with the following one:

Average Spread :=
CALCULATE(
    AVERAGE( 'Range 1'[Spread] );
    ALLSELECTED( Range[CAT_PRIMARY_KEY] );
    ALL(
        'Range 1'[CAT_FOREIGN_KEY];
        'Range 1'[Part]
    )
)

 

That should work.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

But there is one issue here that is the slicer is based on PRIMARY KEY whereas pivot table is based on FOREIGN KEY. So the selection of items in the slicer is not changing the categories in the pivot, though the calculations are working correctly. If PK is used for pivot table then part names are not according to the FK table. Is there a way around for this?

CNENFRNL
Community Champion
Community Champion

Fundamental calculations with DAX

Screenshot 2021-06-17 104022.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Thank you @CNENFRNL for the reply but my expectation is to use the average of column in the pivot measure which I was unable to since the value gets broken down according to the rows of the pivots.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors