The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have three tables with the following columns in my data model:
Store lookup [store_id]
Product_lookup [Product_Id]
and the fact table:
Sales by store: [Product], [Store_id], [quantity] and [unit_price]
I have two measures with the following code:
Solved! Go to Solution.
Hi @arunbyc
When ALLEXCEPT is used as a modifier within CALCULATE, it removes filters on all columns of the expanded table provided in the first argument, except for columns/tables listed in the 2nd argument onwards.
There is no way to use ALLEXCEPT to remove filters from columns of all tables except for specified columns.
So the modifier
ALLEXCEPT ( 'Store Lookup', 'Store Lookup'[store_city] )
For that reason, the results you are getting appear consistent with how ALLEXCEPT should work.
Here are some examples of alternative measures that I think would give results close to what you were expecting:
A measure that would ignore filters from all tables but retain any filters on 'Store Lookup'[store_city] would be:
sales_by_City =
CALCULATE (
[Sales],
REMOVEFILTERS (), -- or ALL ()
FILTERS ( 'Store Lookup'[store_city] ) -- retain filters on this specific column
)
A variation that would do the same but retain visible values of 'Store Lookup'[store_city] would be:
sales_by_City =
CALCULATE (
[Sales],
REMOVEFILTERS (), -- or ALL ()
VALUES ( 'Store Lookup'[store_city] ) -- retain visible values of this specific column
)
Hopefully that helps explain the behaviour you're seeing. Please post back if needed 🙂
Hi @arunbyc
When ALLEXCEPT is used as a modifier within CALCULATE, it removes filters on all columns of the expanded table provided in the first argument, except for columns/tables listed in the 2nd argument onwards.
There is no way to use ALLEXCEPT to remove filters from columns of all tables except for specified columns.
So the modifier
ALLEXCEPT ( 'Store Lookup', 'Store Lookup'[store_city] )
For that reason, the results you are getting appear consistent with how ALLEXCEPT should work.
Here are some examples of alternative measures that I think would give results close to what you were expecting:
A measure that would ignore filters from all tables but retain any filters on 'Store Lookup'[store_city] would be:
sales_by_City =
CALCULATE (
[Sales],
REMOVEFILTERS (), -- or ALL ()
FILTERS ( 'Store Lookup'[store_city] ) -- retain filters on this specific column
)
A variation that would do the same but retain visible values of 'Store Lookup'[store_city] would be:
sales_by_City =
CALCULATE (
[Sales],
REMOVEFILTERS (), -- or ALL ()
VALUES ( 'Store Lookup'[store_city] ) -- retain visible values of this specific column
)
Hopefully that helps explain the behaviour you're seeing. Please post back if needed 🙂
So it seems I got it all wrog. Thanks for clarifying. So, just to get the concept right, shou;ld my code be:
salesBycity =
calculate(
[sales],
allexcept(salesByStore, salesbystore[store_id]
)
on the many side?
Yes, you certainly could use salesByStore as the first argument (assuming that is your fact table), and then specify tables or columns for filters to retain in the second argument.
This would have the effect of removing all filters on columns of salesByStore and related tables related (on the 1-side), except the tables/columns listed.
For the 2nd+ arguments, I would suggest using columns of the 'Store Lookup' table (or the entire 'Store Lookup table) in this case, rather than columns of salesByStore, assuming filters would generally be applied on 'Store Lookup'.
e.g. this to retain just filters on the store_id column
salesBycity =
CALCULATE ( [sales], ALLEXCEPT ( salesByStore, 'Store Lookup'[store_id] ) )
or this to retain any filter from 'Store Lookup':
salesBycity =
CALCULATE ( [sales], ALLEXCEPT ( salesByStore, 'Store Lookup' ) )
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |