Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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???
Solved! Go to Solution.
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
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
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
@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!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
81 | |
76 | |
61 | |
37 | |
33 |
User | Count |
---|---|
99 | |
56 | |
51 | |
42 | |
40 |