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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
thomazinh
Helper I
Helper I

DAX AVERAGEX total result not expected in matrix

I have a matrix where I'm sumarizing by Project and Discipline. The Adjusted Bid Factor values in the Matrix are reading from different What If sliders and displaying those selected results at the row level. I want the Totals in the Matrix to show the average value at Project 1 and Project 2 and finally for the Total. 

 

I expect Project 1's total to be 0.75. Project 2 to be 1.0, and the Total row to be 0.88.

 

thomazinh_1-1659453535447.png

 

Below is my sample code displaying the Adjusted Bid Factor column using the AVERAGEX

_Bid Factor (Selected) AVGX = 
//AVERAGEX('WbsCode Forecast',[_Bid Factor (Selected)])
IF ( HASONEFILTER('WbsCode Forecast'[WbsCode.Discipline.name] ), 
    'WbsCode Forecast'[_Bid Factor (Selected)],
    IF( 
        HASONEFILTER(Jobs[JobName] ),
        AVERAGEX('WbsCode Forecast', 'WbsCode Forecast'[_Bid Factor (Selected)]),
        CALCULATE(
            AVERAGEX( ALLSELECTED(Jobs[JobName] ), 'WbsCode Forecast'[_Bid Factor (Selected)])
        )
    )
)

 

Below is my Bid Factor Selected DAX,

_Bid Factor (Selected) = 
// Pre-req DAX for the _Bid Factor (Selected) AVGX measure. 
// Displays the What If selected value for each of the corresponding Disciplines
VAR ShowSelected = 
    SWITCH( TRUE(),
        CONTAINSSTRING( SELECTEDVALUE('WbsCode Forecast'[WbsCode.Discipline.name]),"PLI"), SELECTEDVALUE('PLI Bid Factor'[PLI Bid Factor]),
        CONTAINSSTRING( SELECTEDVALUE('WbsCode Forecast'[WbsCode.Discipline.name]),"PLF"), SELECTEDVALUE('PLF Bid Factor'[PLF Bid Factor]),
        CONTAINSSTRING( SELECTEDVALUE('WbsCode Forecast'[WbsCode.Discipline.name]),"PFI"), SELECTEDVALUE('PFI Bid Factor'[PFI Bid Factor]),
        CONTAINSSTRING( SELECTEDVALUE('WbsCode Forecast'[WbsCode.Discipline.name]),"PFF"), SELECTEDVALUE('PFF Bid Factor'[PFF Bid Factor]),
        CONTAINSSTRING( SELECTEDVALUE('WbsCode Forecast'[WbsCode.Discipline.name]),"SMI"), SELECTEDVALUE('SMI Bid Factor'[SMI Bid Factor]),
        CONTAINSSTRING(SELECTEDVALUE('WbsCode Forecast'[WbsCode.Discipline.name]),"SMF"), SELECTEDVALUE('SMF Bid Factor'[SMF Bid Factor]),
    1
)
Var Result = 
    IF(ISINSCOPE('WbsCode Forecast'[WbsCode.Discipline.name]),ShowSelected,0) //Displays the rollup value for the Bid Factor starting at the WBS level
Return
 Result 

 

Can someone help me remedy the Total values in the matrix to show the average instead of what it currently is? 

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@thomazinh This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Also, this may come in handy as well, MM3TR&R: Matrix Measure Total Triple Threat Rock & Roll - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.

Top Solution Authors