0
votes

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

1 Answers

1
votes

It looks like your percentage column is a calculated column rather than a measure. Calculated columns cannot be responsive to slicers as they are calculated only once per data load.

Try creating Percentage as a measure instead:

Percentage = SUM(Table1[Value]) / CALCULATE( SUM(Table1[Value]), ALLSELECTED(Table1) )