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.
Hi All,
This simple CALCULATE measure is testing my fundamental DAX understanding and I would like to draw from your wisdom.
The following screenshot should explain the situation, but I will explain further below:
I have this table:
Code | Category | Period |
1 | A | P1 |
2 | A | P2 |
3 | B | P2 |
4 | C | P1 |
I created a measure: "Count Of P2" to count the number of rows with Period = P2 as follows:
Solved! Go to Solution.
Hi there @MarianoG
This admittedly unintuitive behaviour has do with auto-exist, in particular how it behaves when multiple filters are applied on the same table.
This article explains what's going on better than I could, with a similar example to yours:
https://www.sqlbi.com/articles/understanding-dax-auto-exist/
This behaviour can rear its head when filters are applied on columns of the same table, and you remove one of the filters via DAX with ALL or REMOVEFILTERS. The DAX query that is generated by the visual uses SUMMARIZECOLUMNS, which combines filters on the same table into a single filter, which effectively includes only existing combinations of the columns filtered. Removing the filter on one of the columns via DAX (in this case the Period column) does not remove the effect of the other column (Category) having been limited as a result of the original Period filter.
What can you do about it?
One solution is to move Category and Period to related dimension tables (i.e. create a star schema), and filter on columns in those tables instead.
Regards,
Owen
Thanks Owen!
Great explanation.
Hi there @MarianoG
This admittedly unintuitive behaviour has do with auto-exist, in particular how it behaves when multiple filters are applied on the same table.
This article explains what's going on better than I could, with a similar example to yours:
https://www.sqlbi.com/articles/understanding-dax-auto-exist/
This behaviour can rear its head when filters are applied on columns of the same table, and you remove one of the filters via DAX with ALL or REMOVEFILTERS. The DAX query that is generated by the visual uses SUMMARIZECOLUMNS, which combines filters on the same table into a single filter, which effectively includes only existing combinations of the columns filtered. Removing the filter on one of the columns via DAX (in this case the Period column) does not remove the effect of the other column (Category) having been limited as a result of the original Period filter.
What can you do about it?
One solution is to move Category and Period to related dimension tables (i.e. create a star schema), and filter on columns in those tables instead.
Regards,
Owen
User | Count |
---|---|
16 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
23 | |
13 | |
13 | |
8 | |
8 |