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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
smpa01
Super User
Super User

Seeking ALLEXCEPT Behaviour explanation

Hello experts,

I am trying to understand how ALLEXPECT behaves in a measure when multiple tables are involved.

e.g. I have the following two tables

Table Name - Left

Left.indexLeft.nameLeft.jk
1aa-1
2aa-2
3aa-3
4aa-4
1bb-1
2bb-2
3bb-3

Table name-Right

Right.indexRight.nameRight.valueRight.Index.1Right.jk
1a1001a-1
2a2002a-2
3a3003a-3
4a4004a-4
1b5005b-1
2b6006b-2
3b7007b-3

 

Relationship wise Left filters Right based on jk (joinkey) column

Capture.PNG

My desired output is following where I want to display the max of value grouped by name

 

Right.indexRight.nameRight.valueOutput
1a100400
2a200400
3a300400
4a400400
1b500700
2b600700
3b700700

 

I can easily show this with the following measure when I pull everything only from the Right Table

 

 

 

Measure 3 = CALCULATE(MAX('right'[Right.value]),ALLEXCEPT('right','right'[Right.name]))

 

 

Capture.PNG

but if I want to display the same by getting the dim columns from left table like follwoing then the measure falls flat. I can't figure why ALLEXCEPT can't retain the grouping in this context.

Capture.PNG

I however got to where I wanted to with Measure2. It is just that I am trying to find an explanation on the ALLEXCEPT behaviour.

 

 

 

Measure2 :=
MAXX (
    FILTER (
        ALLSELECTED ( 'right' ),
        'right'[Right.name] = MAX ( 'right'[Right.name] )
    ),
    CALCULATE ( MAX ( 'right'[Right.value] ) )
)

 

 

 

 

@OwenAuger @MFelix 

Thank you in advance.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @smpa01 

 

First off, I think you will get the result you want with this measure instead:

 

Measure 3 Fixed = 
CALCULATE (
    MAX ( 'right'[Right.value] ),
    ALL ( 'Right' ),
    VALUES ( 'Right'[Right.name] )
)

 

The basic explanation is that ALLEXCEPT removes all filters on columns of the (expanded) table in the first argument, except for existing filters on the remaining arguments. So in order for a filter to be retained, it must exist in the first place.

 

In this data model, the 1:1 relationship means that the expanded table of 'Right' includes all columns of 'Left' (and vice versa).

 

When you use columns from 'Left' in the table visual, there are no filters on columns of 'Right', including 'Right'[name]. So ALLEXCEPT has the effect of clearing all filters on 'Right' and 'Left (due to table expansion) and, in this visual, there are no filters on 'Right'[Name] to retain.

 

[Measure 3 Fixed] instead uses ALL/VALUES, rather than ALLEXCEPT. This clears all filters from 'Right' (and 'Left' due to table expansion), but brings back visible values of 'Right'[Right.name], which takes account of crossfiltering between 'Left' and 'Right.

 

Good article from SQLBI on this general topic:

https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/ 

 

Kind regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @smpa01 

 

First off, I think you will get the result you want with this measure instead:

 

Measure 3 Fixed = 
CALCULATE (
    MAX ( 'right'[Right.value] ),
    ALL ( 'Right' ),
    VALUES ( 'Right'[Right.name] )
)

 

The basic explanation is that ALLEXCEPT removes all filters on columns of the (expanded) table in the first argument, except for existing filters on the remaining arguments. So in order for a filter to be retained, it must exist in the first place.

 

In this data model, the 1:1 relationship means that the expanded table of 'Right' includes all columns of 'Left' (and vice versa).

 

When you use columns from 'Left' in the table visual, there are no filters on columns of 'Right', including 'Right'[name]. So ALLEXCEPT has the effect of clearing all filters on 'Right' and 'Left (due to table expansion) and, in this visual, there are no filters on 'Right'[Name] to retain.

 

[Measure 3 Fixed] instead uses ALL/VALUES, rather than ALLEXCEPT. This clears all filters from 'Right' (and 'Left' due to table expansion), but brings back visible values of 'Right'[Right.name], which takes account of crossfiltering between 'Left' and 'Right.

 

Good article from SQLBI on this general topic:

https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/ 

 

Kind regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

@OwenAuger  many thanks for your time and writing this detailed explanation. I now fully undertand the issue and thanks again for simplifying the complexity behind it.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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