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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jeffreyweir
Helper III
Helper III

ALL function on related table not clearing filters in CALCULATE

Hi folks. I've got a simple data model that looks like below. 

 

relationships.PNG

 

The YearsService Table only exists so that I can force things to display in a particular order.

 

YearsService.PNG

 

In a Table Visual, I've got the YearsService in the column far left, and I'm using the following measure to count how many folk are in each tenure bucket: 

 

HeadCount (Perm) =
CALCULATE (
    SUM ( CTE[EmpCount] ),
    CTE[EmpStatus] <> "Terminated",
    CTE[EmpType] = "Perm"
)

...and I was wanting to calculate how many folk in all buckets, so that I could then calculate a percentage in each:

 

HeadCount All (Perm) =
CALCULATE (
    SUM ( CTE[EmpCount] ),
    CTE[EmpStatus] <> "Terminated",
    CTE[EmpType] = "Perm",
    ALL ( YearsService[YearsService] )
)

...but that ALL doesn't seem to get transmitted to the CTE table, as per the below visual:

 

 

Result.PNG

 

What I expected is that the second column would have the number 493988 in each cell. 

 

What am I missing here?

 

 

 

 

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @jeffreyweir

 

It looks like you've run into the side effects of the "sort by column" feature.

See this article:

https://www.sqlbi.com/articles/side-effects-in-dax-of-the-sort-by-column-setting/

 

In short, when you have a visual containing a filter on the "sorted" column, the "sort by" column is also added to the filter context , so you need to clear filters on both if you want to effectively remove the effect of the sorted column.

 

In your case I would recommend removing filters on the entire YearsService table, by changing your measure to:

HeadCount All (Perm) =
CALCULATE (
    SUM ( CTE[EmpCount] ),
    CTE[EmpStatus] <> "Terminated",
    CTE[EmpType] = "Perm",
    ALL ( YearsService )
)

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 @jeffreyweir

 

It looks like you've run into the side effects of the "sort by column" feature.

See this article:

https://www.sqlbi.com/articles/side-effects-in-dax-of-the-sort-by-column-setting/

 

In short, when you have a visual containing a filter on the "sorted" column, the "sort by" column is also added to the filter context , so you need to clear filters on both if you want to effectively remove the effect of the sorted column.

 

In your case I would recommend removing filters on the entire YearsService table, by changing your measure to:

HeadCount All (Perm) =
CALCULATE (
    SUM ( CTE[EmpCount] ),
    CTE[EmpStatus] <> "Terminated",
    CTE[EmpType] = "Perm",
    ALL ( YearsService )
)

Regards,

Owen


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

Ahhh! Good to know. Thanks Owen. Hopefully see you at the next Difinity so I can buy you a beer in gratitude. 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.