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
TariqArnabi
Frequent Visitor

nest calculation that needs a filter statement on it with an IN statement not working

I have a nest calculation that needs a filter statement on it with an in statement can anyone help me figure out why this is not working?


Industry Average =

VAR Slicer =
    SELECTEDVALUE ( 'Benchmark Slicer'[Slicer] )
VAR Fail_Count =
    CALCULATE (
        COUNT ( 'SafetyRpts JobData'[SubCategoryName] ),
        'SafetyRpts JobData'[ItemPassFail] = "F"
            && 'SafetyRpts JobData'[ImmediatelyCorrected] = "Y"
    )
VAR Pass_Count =
    CALCULATE (
        COUNT ( 'SafetyRpts JobData'[SubCategoryName] ),
        'SafetyRpts JobData'[ItemPassFail] = "P"
    )
VAR Result =
    SWITCH (
        TRUE (),
        Slicer = "Regional",
            CALCULATE (
                DIVIDE (
                    IF (
                        AND (
                            MAX ( 'SafetyRpts JobData'[ItemPassFail] ) = "F",
                            MAX ( 'SafetyRpts JobData'[ImmediatelyCorrected] ) = "Y"
                        )
                            || MAX ( 'SafetyRpts JobData'[ItemPassFail] ) = "P",
                        Fail_Count + Pass_Count
                    ),
                    CALCULATE ( COUNT ( 'SafetyRpts JobData'[SubCategoryName] ) ),
                    FILTER (
                        VALUES ( 'SafetyRpts InspectionData' ),
                        'SafetyRpts InspectionData'[AccountName] = ( [Find Client Region] )
                    )
                ),
                Slicer = "Inpector",
                (
                    CALCULATE (
                        DIVIDE (
                            IF (
                                AND (
                                    MAX ( 'SafetyRpts JobData'[ItemPassFail] ) = "F",
                                    MAX ( 'SafetyRpts JobData'[ImmediatelyCorrected] ) = "Y"
                                )
                                    || MAX ( 'SafetyRpts JobData'[ItemPassFail] ) = "P",
                                Fail_Count + Pass_Count
                            ),
                            CALCULATE ( COUNT ( 'SafetyRpts JobData'[SubCategoryName] ) )
                        )
                    )
                ),
                Slicer = "Global",
                (
                    CALCULATE (
                        DIVIDE (
                            IF (
                                AND (
                                    MAX ( 'SafetyRpts JobData'[ItemPassFail] ) = "F",
                                    MAX ( 'SafetyRpts JobData'[ImmediatelyCorrected] ) = "Y"
                                )
                                    || MAX ( 'SafetyRpts JobData'[ItemPassFail] ) = "P",
                                Fail_Count + Pass_Count
                            ),
                            CALCULATE ( COUNT ( 'SafetyRpts JobData'[SubCategoryName] ) )
                        )
                    )
                )
            )
    )
RETURN
    Result

1 REPLY 1
v-xiaotang
Community Support
Community Support

Hi @TariqArnabi 

Thanks for reaching out to us.

Please return each variable in turn to check whether the return value is correct. If there is no problem with their return values, could you please provide some sample data for us to investigate further? Thanks

 

Best Regards,

Community Support Team _Tang

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

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.