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
Budfudder
Helper IV
Helper IV

SUM Ignoring Slicers

My visual has a simple data table which has a number of rows, each representing an invoice. Each invoice has a number of items, including the sales rep, creation date, and the amount.

 

I have a number of slicers including sales rep, date of creation, etc.

 

I'm trying to add a column which, for each row, shows the percentage that that particular invoice is of the shown invoices. So, for example, when I use a filter to only show a subset of all rows, I want each row to show a percentage of the total of that subset, not the percentage of all rows.

 

Imagine this table:

|ID|Rep |Value|Percentage|
| 1|Dave|   10|        50|
| 2|Sue |    3|        15|
| 3|Dave|    5|        25|
| 4|Sue |    2|        10|

The Percentage column is created by Value/SUM(Value) and is showing correctly above. The SUM(Value) is 20; Dave's 10 is 50% of that, Sue's 3 is 15% of it, and so forth.

 

I have a slicer for Rep. So if I choose 'Dave' in that slicer, the table looks like this:

|ID|Rep |Value|Percentage|
| 1|Dave|   10|        50|
| 3|Dave|    5|        25|

The Percentage column is being created based on the SUM(Value) of ALL rows (i.e. 20) not just the ones that are showing because of my slicer (i.e. 15). I would have expected the percentages to be 66.67% and 33.33%, being the percentages of the total of what's showing. Why isn't it? And how do I get it to be?

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @Budfudder

 

It's the difference between ALL() and ALLSELECTED()

 

I have the following measures in the view below 

Values = SUM( Table1[Value] )

Values ALL = CALCULATE( [Values] , ALL ( Table1 ) )
Values ALL Selected = CALCULATE ( [Values] , ALLSELECTED ( Table1 ) )

% of total ALL = DIVIDE( [Values] , [Values ALL] , 0 )
% of total ALL Selected = DIVIDE( [Values] , [Values ALL Selected] , 0 )

With no slicer selection the amounts from [Values ALL] and [Values ALL Selected] are the same.

all_no_filter.jpg

 

If I apply a filter on Dave [Values ALL] ignores that filter while [Values ALL Selected] respects it.

all_filtered.jpg

 

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

Hello @Budfudder

 

It's the difference between ALL() and ALLSELECTED()

 

I have the following measures in the view below 

Values = SUM( Table1[Value] )

Values ALL = CALCULATE( [Values] , ALL ( Table1 ) )
Values ALL Selected = CALCULATE ( [Values] , ALLSELECTED ( Table1 ) )

% of total ALL = DIVIDE( [Values] , [Values ALL] , 0 )
% of total ALL Selected = DIVIDE( [Values] , [Values ALL Selected] , 0 )

With no slicer selection the amounts from [Values ALL] and [Values ALL Selected] are the same.

all_no_filter.jpg

 

If I apply a filter on Dave [Values ALL] ignores that filter while [Values ALL Selected] respects it.

all_filtered.jpg

 

Anonymous
Not applicable

@jdbuchanan71 

I have single table. I need to  get the (sum of Actual hours by an Employee )/ Sum(of Actual Hours in that Project irrespective of Employee) in a DAX measure. Can you please suggest how can I do it.

Sample Output

 

For example if I put a slicer for employee A

ProjectIDActual hours ProjectHoursMeasure
1173617/36
49199/19

 

 

Sample Table DATA: 

ProjectIDEmployee IDActual Hours
1A12
2A13
3B8
4A9
4B10
1C9
1A5
1B10

Hello @Anonymous 

Give this a try.

Measure = 
VAR _Employee = SUM ( YourTable[Actual Hours] )
VAR _Project = CALCULATE ( SUM ( YourTable[Actual Hours] ), ALL ( YourTable[Employee ID] ) )
RETURN DIVIDE ( _Employee, _Project )

 2020-02-28_9-29-05.jpg

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.