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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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