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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
thomazinh
Helper I
Helper I

Averagex not working to calculate average in matrix

I have a matrix where I am expecting to get an average value for the Total rows in the Adjusted Bid Factor column.

 

The Adjusted Bid Factor column is using a What If value that I'm referencing called _Bid Factor (Selected). The matrix row structure is (lowest to highest) Discipline Name to Project Name. I tried using HASONEFILTER but was unsuccessful. I'm doing something similar with SUMX on Forecasted Actual Cost and have no issues. 

 

thomazinh_1-1659453535447.png

 

 

On the above matrix, I would expect the top total for the Project to be the 0.75 (=(1.00+0.50)/2) but it is returning 0.63. For the Total row, I would expect 0.88 (=(1.0+1.0+1.0+0.5)/4). 

 

The _Bid Factor (Selected) DAX doesn't give me any issues,

 

_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 

 

 

Below is what I have for the _Bid Facotr (Selected) AVGX DAX, 

 

_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 similar code for the Forecasted Actual Cost column, 

_Productive Labor Field (Forecasted Actual Cost) SUMX = 
       IF (
            HASONEFILTER ( 'WbsCode Forecast'[WbsCode.Discipline.display] ),
            [_Productive Labor Field (Forecasted Actual Cost)],
            IF (
                    HASONEFILTER ( Jobs[JobName] ),
                    [_Productive Labor Field (Forecasted Actual Cost)],
                    CALCULATE (
                        SUMX (
                            ALLSELECTED ( Jobs[JobName] ),
                            [_Productive Labor Field (Forecasted Actual Cost)]
                        )
                    )
                )
            )

 

 

Is there a way to calculate the avereage for the Adjusted Bid Factor column?

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @thomazinh 

 

Can you mock up some dummy data and paste it here so that we can use it for testing the measures? Which tables are involved in this matrix? Can you elaborate the relationships between them?https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-... 

 

Best Regards,
Community Support Team _ Jing

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors