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! Request now

Reply
Ezhilmathi
Frequent Visitor

Average on condition - Matrix

Hi All,

I want to calculate the percentage average of a column which has 0 1 and 0 in which 0 means atleast 1 job had failed and 1 means no failures. This must be shown in a matrix visual and by all the level of hierarchies of date i.e Year, Quarter, Month, Week, Date. The count of 1s in the column must be calculated and then the average of the column in week, month, quarter, year, project, etc.
I am struck on how to find the % average of the 1s in the column by week i.e. Count(1)/Count(1+0) in the column by all the hierarchy.

 

avg_test =
CALCULATE(AVERAGE(Prod_Jobs_Snow[IsJobFailed]),
ALLEXCEPT(Prod_Jobs_Snow, Prod_Jobs_Snow[Product], Prod_Jobs_Snow[Project], Dim_Date[Year], Dim_Date[Quarter], Dim_Date[Month], Dim_Calendar[Week of Month],Dim_Date[Date]))

 

This is my current formula and don't get the correct answer wher inserted if condition to them to filter out 1s in the column.

Ezhilmathi_0-1665482727156.png

For example, from the above image, the average value of week 5 should be Count(100s)/Count(100s+0s) = 5/6. But I am getting the overall percentage instead. 


Would appreciate any help on this.

 

 

1 ACCEPTED SOLUTION
v-yinliw-msft
Community Support
Community Support

Hi @Ezhilmathi ,

 

You can try this method:

avg_test = 
VAR _Count1 =
    CALCULATE (
        COUNT ( Prod_Jobs_Snow[IsJobFailed] ),
        FILTER (
            ALL ( Prod_Jobs_Snow ),
            [IsJobFailed] = 0
                && [Product] = MAX ( Prod_Jobs_Snow[Product] )
                && [Project] = MAX ( Prod_Jobs_Snow[Project] )
        ),
        ALLEXCEPT ( Dim_Date, Dim_Date[Year], Dim_Date[Quarter], Dim_Date[Month] ),
        ALLEXCEPT ( Dim_Calendar, Dim_Calendar[Week of Month] )
    )
VAR _Count2 =
    CALCULATE (
        COUNT ( Prod_Jobs_Snow[IsJobFailed] ),
        ALLEXCEPT ( Prod_Jobs_Snow, Prod_Jobs_Snow[Product], Prod_Jobs_Snow[Project] ),
        ALLEXCEPT ( Dim_Date, Dim_Date[Year], Dim_Date[Quarter], Dim_Date[Month] ),
        ALLEXCEPT ( Dim_Calendar, Dim_Calendar[Week of Month] )
    )
RETURN
    DIVIDE ( _Count1, _Count2 )

vyinliwmsft_0-1666235196888.png

 

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

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

1 REPLY 1
v-yinliw-msft
Community Support
Community Support

Hi @Ezhilmathi ,

 

You can try this method:

avg_test = 
VAR _Count1 =
    CALCULATE (
        COUNT ( Prod_Jobs_Snow[IsJobFailed] ),
        FILTER (
            ALL ( Prod_Jobs_Snow ),
            [IsJobFailed] = 0
                && [Product] = MAX ( Prod_Jobs_Snow[Product] )
                && [Project] = MAX ( Prod_Jobs_Snow[Project] )
        ),
        ALLEXCEPT ( Dim_Date, Dim_Date[Year], Dim_Date[Quarter], Dim_Date[Month] ),
        ALLEXCEPT ( Dim_Calendar, Dim_Calendar[Week of Month] )
    )
VAR _Count2 =
    CALCULATE (
        COUNT ( Prod_Jobs_Snow[IsJobFailed] ),
        ALLEXCEPT ( Prod_Jobs_Snow, Prod_Jobs_Snow[Product], Prod_Jobs_Snow[Project] ),
        ALLEXCEPT ( Dim_Date, Dim_Date[Year], Dim_Date[Quarter], Dim_Date[Month] ),
        ALLEXCEPT ( Dim_Calendar, Dim_Calendar[Week of Month] )
    )
RETURN
    DIVIDE ( _Count1, _Count2 )

vyinliwmsft_0-1666235196888.png

 

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors