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

Get certified as a Fabric Data Engineer: Check your eligibility for a 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700. 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
Super User
Super User

@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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.