Forum Discussion

ahmedshalabyy12's avatar
10 months ago
Solved

problem with all except

Dears,   I’m trying to display the total amount (8M) for each organization in every row of the matrix, but it’s not working as expected. Org Name comes from Dim_Organizations Recommended Amou...
  • Ahmed-Elfeel's avatar
    10 months ago

    Hi ahmedshalabyy12,

     

    The issue here that is you are applying this to two different tables which is causing unexpected behavior

     

    Your current measure:

    Rec_Amount =
    CALCULATE (
        [Total Amount (Sum)],
        ALLEXCEPT ( Organizations, Organizations[Organization Name] ),
        ALLEXCEPT ( Terms, Terms[TermYears] )
    )

    This is saying "Remove all filters except Organization Name from the Organizations table AND remove all filters except TermYears from the Terms table (This creates conflicting filter contexts)

     

    You need to use ALLEXCEPT on the fact table (or use a different approach) to ignore the TermYears filter while keeping the Organization Name filter

     

    So you can use ALLEXCEPT on the fact table (if possible)

    Rec_Amount =
    CALCULATE (
        [Total Amount (Sum)],
        ALLEXCEPT ( Fact_Table, Organizations[Organization Name] )
    )

     

    Or use REMOVEFILTERS for more precise control

    Rec_Amount =
    CALCULATE (
        [Total Amount (Sum)],
        Organizations[Organization Name] = SELECTEDVALUE(Organizations[Organization Name]),
        REMOVEFILTERS ( Terms )
    )

     

     

    You can also ALL with VALUES (most reliable)

    Rec_Amount =
    CALCULATE (
        [Total Amount (Sum)],
        ALL ( Terms ),
        VALUES ( Organizations[Organization Name] )
    )

     

    This will:

    • Remove any filtering from the Terms table (including TermYears)

    • Preserve the current Organization Name filter

    • Show the total $8M for (Black Futures Lab) in every row of your matrix

    if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.