Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
I'm starting to learn DAX and have a very simple question:
I have two tables: Project and Project Status
Solved! Go to Solution.
Since the default filtering direction is from the one-side to the many-side and not the other way round (unless you switch on the bi-directional filtering but YOU SHOULD NOT DO SO), if you put a filter on a column in the many-side table, the filter will NOT propagate to the one-side table. Hence, counting rows in the one-side table will return 3, that is, all the rows in the table (since no filtering occurs). The rule of dimensional modeling, which is the basis for Power BI, is that you should only select attributes from dimensions (the one-side table) and keep fact tables (the many-side) hidden and never select anything from it (with very, very, very few exceptions).
This also means that you should have a separate dimension with statuses and connect it to the fact table. Then you can select projects from the Projects dimension and statuses from the Statuses dimension. Your measure that will then calculate correctly (regardless of anything) the number of different projects with the selected statuses is:
[# Projects] = distinctcount( 'Project Status'[ProjectId] )
Easy.
Please remember that 'Project Status' is a fact table and must be hidden (you should not select from it). Regarding the formula that @wdx223_Daniel gave you... Yes, it'll work but it's very inefficient and such techniques (his one uses the Expanded Tables Theory) should be avoided, especially with big fact tables. Just try to run his formula on a really big fact table and you'll see why.
Since the default filtering direction is from the one-side to the many-side and not the other way round (unless you switch on the bi-directional filtering but YOU SHOULD NOT DO SO), if you put a filter on a column in the many-side table, the filter will NOT propagate to the one-side table. Hence, counting rows in the one-side table will return 3, that is, all the rows in the table (since no filtering occurs). The rule of dimensional modeling, which is the basis for Power BI, is that you should only select attributes from dimensions (the one-side table) and keep fact tables (the many-side) hidden and never select anything from it (with very, very, very few exceptions).
This also means that you should have a separate dimension with statuses and connect it to the fact table. Then you can select projects from the Projects dimension and statuses from the Statuses dimension. Your measure that will then calculate correctly (regardless of anything) the number of different projects with the selected statuses is:
[# Projects] = distinctcount( 'Project Status'[ProjectId] )
Easy.
Please remember that 'Project Status' is a fact table and must be hidden (you should not select from it). Regarding the formula that @wdx223_Daniel gave you... Yes, it'll work but it's very inefficient and such techniques (his one uses the Expanded Tables Theory) should be avoided, especially with big fact tables. Just try to run his formula on a really big fact table and you'll see why.
@Anonymous try this code
=calculate (distinctcount (project[projectid]),'project status')
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
17 | |
10 | |
9 | |
8 | |
7 |
User | Count |
---|---|
20 | |
11 | |
8 | |
6 | |
6 |