Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Need Help with Advanced Filtering Logic in Power BI Data Model

Hello everyone,

I'm working on a Power BI report and facing a challenge with implementing dynamic filter functionality. Here's a high-level overview of my data model and the issue:

 

**Data Model Overview:**

 

  1. **Transactions Table**:

  - Granularity: Individual transaction records.

  - Key Columns: TransactionDate (Year, Month, Day), PartnerID, EntityIDHashKey (represents unique entities), TransactionHashKey, RevenueAmount.

 - A PartnerID can have more than 1 EntityIDHashKey  under it.

YearMonthDayPartnerIDEntityHashKeyTransactionHashKeyRevenueAmount
20243210020030025.27
202432100201301183.2
202433102200302173.13
20243310320130313.8

 

  1. **EntityAttributes Table**:

  - Granularity: Attribute level of entities.

  - Key Columns: EntityID, EntityIDHashKey, AttributeGroupName, AttributeCategory.

  - Each Entity can have 1 AttributeGroupName which falls into only 1 AttributeCategory or can have more than 1 AttributeGroupName which can fall into more than 1 AttributeCategory.

EntityHashKeyAttributeGroupNameAttributeCategory
200AMCGroup1AMC Category
200NXTGroup2AMC Category
201YLMGroup1AMC Category
201UxYTGroup2UYT Category
202POPGroup1POP Category
203UYTGroup7UYT Category

 

  1. **Entities Table**:

  - Granularity: Each unique entity.

  - Key Columns: EntityID, EntityHashKey, PartnerID.

 

Relationships:

EntityAttributes  table Joins with Entities Table on EntityIDHashKey (Many to One)

Entities Table joins with Transactions Table on EntityIDHashKey (One to Many)

 

**Current Blocker/Requirement:**

We have `AttributeCategory` filter in the report. The data model involves complex relationships where an entity can be linked to multiple attributes or attribute groups. The filter should support both exclusive and inclusive filtering:

 

- **Exclusive Filtering**: When a single `AttributeCategory` is selected, the report should show data related to only that category, excluding entities associated with other categories, even if they are part of the selected category.
Ex: If user selects "AMC Category", the report should filter data only for EntityHashKey - 200, and excluding EntityHashKey 203 because it has both "AMC Category" and "UYT Category".

- **Inclusive Filtering**: When multiple `AttributeCategories` are selected, the report should reflect data for entities associated exclusively with those selected categories.
Ex: If user selects both "AMC Category", and "UYT Category", the report should filter data only for EntityHashKey - 201. The filtering mechanism should exclude others because they have other categories as well.

 

**Additional Considerations:**

- We are using a semantic model for the Power BI dataset; hence calculated columns or calculated tables, and measure-based filters are not feasible.

 

Any guidance or advice on how to approach this problem would be greatly appreciated. Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

 

You can create a measure as a filter field to achieve the desired result. I made a test with below measure. It works in a report which live connects to a semantic model. 

Measure = 
VAR _curEntity = SELECTEDVALUE('Transactions Table'[EntityHashKey])
VAR _selectCats = CALCULATETABLE(VALUES('EntityAttributes Table'[AttributeCategory]),ALLSELECTED('EntityAttributes Table'))
VAR _curCats = CALCULATETABLE(VALUES('EntityAttributes Table'[AttributeCategory]),ALL('EntityAttributes Table'),'EntityAttributes Table'[EntityHashKey] = _curEntity)
VAR _commonCats = INTERSECT(_curCats,_selectCats)
RETURN
IF(COUNTROWS(_commonCats)=COUNTROWS(_selectCats)&&COUNTROWS(_commonCats)=COUNTROWS(_curCats),1,0)

vjingzhanmsft_0-1709704439762.png

vjingzhanmsft_1-1709704460596.png

 

Hope this would be helpful. 

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous 

 

You can create a measure as a filter field to achieve the desired result. I made a test with below measure. It works in a report which live connects to a semantic model. 

Measure = 
VAR _curEntity = SELECTEDVALUE('Transactions Table'[EntityHashKey])
VAR _selectCats = CALCULATETABLE(VALUES('EntityAttributes Table'[AttributeCategory]),ALLSELECTED('EntityAttributes Table'))
VAR _curCats = CALCULATETABLE(VALUES('EntityAttributes Table'[AttributeCategory]),ALL('EntityAttributes Table'),'EntityAttributes Table'[EntityHashKey] = _curEntity)
VAR _commonCats = INTERSECT(_curCats,_selectCats)
RETURN
IF(COUNTROWS(_commonCats)=COUNTROWS(_selectCats)&&COUNTROWS(_commonCats)=COUNTROWS(_curCats),1,0)

vjingzhanmsft_0-1709704439762.png

vjingzhanmsft_1-1709704460596.png

 

Hope this would be helpful. 

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

Anonymous
Not applicable

Thank you Jing !!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.