+ Reply to Thread
Results 1 to 5 of 5

DAX ALLEXCEPT vs ALL & VALUES

  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    647

    DAX ALLEXCEPT vs ALL & VALUES

    Hi have a pivot table where I have used ;

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    in the pivot these both give the same result a total for the items ignore everything else, this is attached,
    but if I go to studio or Table Edit DAX and run the following

    EVALUATE
    ADDCOLUMNS( Table1,
    "N", CALCULATE( [Tsales] , ALLEXCEPT(Table1,Table1[Item])))

    EVALUATE
    ADDCOLUMNS( Table1,
    "M", CALCULATE( [Tsales], ALL( Table1), VALUES( Table1[Item] ) ))



    I get two different result the all values seems to ignore the values and bring back the overall total? what am I doing wrong?

    Richard.
    Attached Files Attached Files

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,298

    Re: DAX ALLEXCEPT vs ALL & VALUES

    VALUES( Table1[Item] ) is evaluated in the current filter context. Since it's a calculated column, there is no filter context, only row context, so that is actually returning all the Item values. Your ALL function then removes all the filters created by context transition, so the VALUES function may as well not be there. When you use ALLEXCEPT, the Item filter created by transition from row context to filter context is not cleared, but all the other column filters are, so you end up with just a filter for the Item.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    647

    Re: DAX ALLEXCEPT vs ALL & VALUES

    Ok, but I still don't see why in DAX studio, it does not work when say this from sqlbi does.


    Please Login or Register  to view this content.
    REMOVE is not available in p pivot, which is what I'm using, but the construction is the same, and in a pivot table works better
    than ALLEXCEPT as you have to have the column being 'excepted' in the table but with ALL VALUES it need not be present.

    Richard.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: DAX ALLEXCEPT vs ALL & VALUES

    but if I go to studio or Table Edit DAX and run the following

    EVALUATE
    ADDCOLUMNS( Table1,
    "N", CALCULATE( [Tsales] , ALLEXCEPT(Table1,Table1[Item])))
    ...
    As @rompersomper mentioned. This is evaluated within row context of the table. And not within filter context of pivot table.

    What you posted in post#3 is measure calculated within filter context and not calculated column evaluated on table row context.

    EDIT: DAX is highly contextual and relies on evaluation context to provide dynamic analysis. Have a read of...
    https://www.sqlbi.com/articles/row-c...ontext-in-dax/
    and
    https://support.microsoft.com/en-us/...related%20data.
    Last edited by CK76; 05-07-2024 at 09:16 AM.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  5. #5
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    647

    Re: DAX ALLEXCEPT vs ALL & VALUES

    Thanks for the links, I will have a read through, it's not a major practical issue I was just curious.

    I'll mark this up,

    Thanks to both of you.

    Richard.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. DAX Calculated column ALLEXCEPT v ALL / Values;
    By Dicken in forum Office 365
    Replies: 4
    Last Post: 09-19-2023, 10:28 AM
  2. Dax allexcept
    By Dicken in forum Office 365
    Replies: 1
    Last Post: 04-09-2023, 02:28 PM
  3. DAX ALLEXCEPT vs ALL & VALUES
    By Dicken in forum Office 365
    Replies: 0
    Last Post: 03-31-2023, 09:37 AM
  4. Dax allexcept
    By Dicken in forum Office 365
    Replies: 0
    Last Post: 01-28-2023, 09:56 AM
  5. DAX ALLEXCEPT versus ALL & VALUES in Power Pivot
    By Dicken in forum Office 365
    Replies: 4
    Last Post: 08-04-2022, 09:17 AM
  6. Replies: 0
    Last Post: 07-10-2022, 11:34 AM
  7. assigning date entries to week values and month values to sum column C-N values C-
    By the accountant in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2010, 09:52 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1