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
Anonymous
Not applicable

Filter table by selected client's region

Hello,

 

I have the following issue, which I have been trying to solve for a while. After months lurking the forums, I figured it was time to post my first question.

 

My data has orders, clients, and regions among other attributes. I have a matrix visual with salespeople in the rows and my order measures on the columns. I want to design a measure such that when a client is selected in another visual, the matrix visual cross-filters to show the amount of orders for that client's region.

 

This has been my approach so far, or variants:

 

CALCULATE (
    SUM ( Sales[Orders] );
    ALL ( 'Clients'[ClientCode] );
    VALUES ( 'Clients'[Region] )
)

I have tried changing the order of the calculate modifiers, I have tried using SELECTEDVALUE( ) and LOOKUPVALUE( ), but to no avail.

The requirement seems easy enough but filters must be overriding or something because I cannot wrap my head around the inner workings of this formula.

 

Any help or pointers in the right direction would be extremely appreciated.

Thank you very much in advance and kind regards,

 

Alex

2 ACCEPTED SOLUTIONS
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try removing filters from all 'Clients'

 

CALCULATE (
    SUM ( Sales[Orders] );
    ALL ( 'Clients' );
    VALUES ( 'Clients'[Region] )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

View solution in original post

Hi @Anonymous 

 

This expression is ignoring filter applied to 'Clients'[ClientCode] only, all other filters on attributes within the 'Clients' dimension are preserved.

  1. replying filters by  VALUES ( 'Clients'[Region] ) is not necessary, as this filter was not ignored by ALL( 'Clients'[ClientCode] )
  2. adding any other attribute from the 'Clients' dimension, for example, 'Clients'[City] would add it to filter context and result in every 'Clients'[ClientCode] duplicating SUM( Sales[Orders] ) value for this City.
  3. To ensure the above is not happening you need to ignore all filters coming to form Clients Dimension and apart from the 'Clients'[Region].
CALCULATE (
    SUM ( Sales[Orders] );
    ALL ( 'Clients'[ClientCode] );
    VALUES ( 'Clients'[Region] )
)

In reference to the workshop that you have been attending, this is true and you should do it whenever possible or logical, it brings most benefits when you preforming iterations.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

View solution in original post

3 REPLIES 3
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try removing filters from all 'Clients'

 

CALCULATE (
    SUM ( Sales[Orders] );
    ALL ( 'Clients' );
    VALUES ( 'Clients'[Region] )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Anonymous
Not applicable

Hi @Mariusz,

 

Thank you so much, that worked wonders!

 

However, could you explain a little bit why it works, please? I have heard in some DAX workshops that you should not filter full tables, but instead only the columns you intend to use. Is your answer an exception to this?

 

Thanks again!

 

Alex

Hi @Anonymous 

 

This expression is ignoring filter applied to 'Clients'[ClientCode] only, all other filters on attributes within the 'Clients' dimension are preserved.

  1. replying filters by  VALUES ( 'Clients'[Region] ) is not necessary, as this filter was not ignored by ALL( 'Clients'[ClientCode] )
  2. adding any other attribute from the 'Clients' dimension, for example, 'Clients'[City] would add it to filter context and result in every 'Clients'[ClientCode] duplicating SUM( Sales[Orders] ) value for this City.
  3. To ensure the above is not happening you need to ignore all filters coming to form Clients Dimension and apart from the 'Clients'[Region].
CALCULATE (
    SUM ( Sales[Orders] );
    ALL ( 'Clients'[ClientCode] );
    VALUES ( 'Clients'[Region] )
)

In reference to the workshop that you have been attending, this is true and you should do it whenever possible or logical, it brings most benefits when you preforming iterations.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

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.

Top Solution Authors