Forum Discussion
Relationship
- 1 year ago
Hi Boopep,
When you select a Province, the Population card is only showing the population for municipalities that exist in your Registration table, not the full province total. This happens because the active relationship between Municipality and Registration is filtering out any municipalities not present in Registration.
You need to adjust your DAX so that at the Province level, it ignores the Registration table filter and returns the full population for the selected province. This is a standard Power BI pattern using REMOVEFILTERS to clear unwanted context.Try using this measure for your Population Card:
Population Card = IF( ISFILTERED('Municipality'[Municipality]), SUM('POP'[POPULATION]), // When a Municipality is selected CALCULATE( SUM('POP'[POPULATION]), REMOVEFILTERS('Konstula Reg') ) // When only a Province is selected )If a Municipality is selected, you get just that value. If a Province is selected, you get the full Province population even if some municipalities aren’t in Registration.
Make sure your Province and Municipality tables are both connected with single-direction relationships to your fact tables. For even more flexibility, you can use HASONEVALUE or ISINSCOPE if you want to handle more complex
- 1 year ago
Hi Boopep
Thank you for contacting the Microsoft Fabric Community Forum.To address the relationship issue between data models, I have created a sample .pbix file to illustrate a possible solution. While the structure may not exactly match your dataset, the example demonstrates the logic using calculated columns and DAX to achieve the intended result.
The solution uses two dimension tables: one for Provinces, listing unique Province names, and another for Municipalities, listing unique Municipality names along with their Provinces. The Province Dimension links to the Municipality Dimension via the Province column, and the Municipality Dimension connects to both the Population and Registration tables through the Municipality column, using one-to-many, single-directional relationships.
I have included the .pbix file to show this method. Please take a look and let us know if this approach meets your needs or if further adjustments are required for your specific data model.
Regards,Karpurapu D,
Microsoft Fabric Community Support Team.
Hi Boopep
Just based on the image, it appears to be because your active relationship is bidirectional. This is jsut based on the image - there may be additional factors involved.
By the way, CALCULATE is redundant in this measure. Measures are implicitly wrapped in CALCULATE in most cases.
% Registered to Population =
DIVIDE(
CALCULATE(SUM('Konsulta Reg'[REG COUNT])),
CALCULATE(SUM('POP'[POPULATION]))
)
So how should the DAX measure be written.