cancel
Showing results for
Did you mean:
Anonymous
Not applicable

## Calculate ALL regardless of slicer

Hi Everyone - Very new to PowerBI so pardon my ignorance - I am sure there is an easy solve for this!

I am trying to create a new column/measure that will calculate all orders regardless of my slicer.

For example, when the slicer is selected for Washington DC I have three values in the graph.  I want the third value (pink line) to show ALL orders, not just Washington DC orders.

I have tried the following to create a new column/measure:

AllOrdersAvg = CALCULATE(AVERAGE(AllMonths[Orders]);ALLSELECTED(AllMonths))

But receive the following error:

The syntax for ';' is incorrect. (DAX(CALCULATE(AVERAGE(AllMonths[Orders]);ALLSELECTED(AllMonths))))

Also tried:

AllOrdersAvg = ALL(AllMonths[Orders])

But received the following error:

A table of multiple values was supplied where a single value was expected.

What am I doing wrong???

1 ACCEPTED SOLUTION
Super User II

Hey,

to remove the existing filter that comes from the slicer try this measure:

```Measure 4 =
CALCULATE(
AVERAGE('AllMonths'[Orders])
,ALL('AllMonths'[name of the column that contains "Washington DC"])
)```

Please be aware that the character that separates arguments inside function depends on your language settings, if you have an english os the above formula should work, but maybe you have to use ;ALL use a semicolon instead of a comma.

Regards,

Tom

Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
3 REPLIES 3
Anonymous
Not applicable

One of the most important things in DAX is the concept of filters.  When you put data into a chart/table/ect, there are filters.  That is why you get a different answers.  With ALL you want to tell DAX to ignore the current filter and use an entire table or an entire column.  A good practice is to never filter an entire table if you can filter a column.

So using the Contoso DB as an example:

1) Create a base measure (which looks like is a count or sum of orders)

`Total Sales = SUM ( Sales[Unit Price] )`

2) Create a measure, using the base measure, that will give you the total regardless of what is selected in a slicer, or what other filter context exist:

```All Sales =
CALCULATE(
[Total Sales],
ALL ('Product'[Brand],'Product'[Color])
)```

So in this example, ALL ignores the filters from the Product Table of Brand and Color. Any other columns will not be ignored, and that filter context will be used to evaluate Total Sales. There is also ALL's cousin, ALLEXCEPT. Output with Product and Color on rows:

ALLSELECTED is an interesting function.  It works like you would expect, most of the time.  It actually removes the current filter context and restores the previous one.  That's a gross oversimplification, but something to keep in mind and maybe explore further.

```All Sales, of only Selected =
CALCULATE(
[Total Sales]
ALLSELECTED ('Product'[Brand],'Product'[Color])  /*Can Also use ALLSELECTED(), which uses the whole data model*/
)```

Hope that helps

Super User II

Hey,

to remove the existing filter that comes from the slicer try this measure:

```Measure 4 =
CALCULATE(
AVERAGE('AllMonths'[Orders])
,ALL('AllMonths'[name of the column that contains "Washington DC"])
)```

Please be aware that the character that separates arguments inside function depends on your language settings, if you have an english os the above formula should work, but maybe you have to use ;ALL use a semicolon instead of a comma.

Regards,

Tom

Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

@TomMartensMany thanks this worked amazingly well and easy; I would have never been able to figure it out myself.  Thank you!

And @Anonymous this looks like a good solution too - thanks!  I will definitely keep it in mind for future reference!

Announcements

#### Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

#### Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

#### Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors