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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
HelloPBIWorld
New Member

Calculate a measure with a filter that doesn't propagate to table

 

The relationships in my model are like below :

  • d_collection_types[Collection type id] is 1 to many to f_collections[Collection_Type_id] with filter direction (unidirection) from d_collection_types to f_collections
  • Dim Account[Account Id] is 1 to many Fact Ledger[Ledger Account Id] with filter direction (unidirection) from Dim Account to Fact Ledger
  • d_balance_mappings[Balance ID] is 1 to many to Fact Ledger[Ledger Balance Id] bidirection from d_balance_mappings to Fact Ledger
  • Dim Account[Client Id] is many to 1 to Dim Client[Client Id] with filter direction (unidirection) from Dim Client to Dim Account
  • Dim Account[Account Id] is 1 to many to f_account_statuses[Account Id] with filter direction (unidirection) from Dim Account to f_account_statuses
  • d_accounts_payment_status[Account payment status id] is 1 to many to f_account_statuses[Account payment status id] with filter direction (unidirection) from d_accounts_payment_status to f_account_statuses

I want  to create a measure Total Ledger Balance Amicable as below but you can see that balance type doesn't filter the fact ledger because of the complexity of the model and the way the relationships are implemented.

The logic behind the measure is :

SUM('Fact Ledger'[Ledger Balance]) where 'd_balance_mappings'[Balance Type] = "Balance" or "Costs"

minus
SUM('Fact Ledger'[Ledger Balance]) where 'd_balance_mappings'[Balance Type] = "Payments"
the result should be for [Collection type] = 'Amicable'

 

How can I achieve this ?

1 ACCEPTED SOLUTION

Hi @HelloPBIWorld 

 

Option A (model fix – best for long term)

Add the Collection_Type_id to the fact (via PQ merge) or create a proper dim that’s on a single filter path to Fact Ledger:
d_collection_types >> f_collections >> Fact Ledger with filters flowing downstream. Then your original measure will work without tricks.

 

Option B (keep model – enforce filter in DAX with TREATAS)

Push the selected collection IDs onto the fact using TREATAS:

 

Total Ledger Balance (by Type) =
VAR SelectedCollectionIDs =
   CALCULATETABLE(
       VALUES ( 'f_collections'[Collection_ID] ),
       // use this if you want slicer-driven type
       KEEPFILTERS ( VALUES ( 'd_collection_types'[Collection type] ) )
       // or hard-code to Amicable:
       // 'd_collection_types'[Collection type] = "Amicable"
   )
VAR BalancePart =
   CALCULATE(
       SUM ( 'Fact Ledger'[Ledger Balance] ),
       'd_balance_mappings'[Balance Type] IN { "Balance", "Costs" },
      TREATAS ( SelectedCollectionIDs, 'Fact Ledger'[Collection_ID] )
   )
VAR PaymentPart =
   CALCULATE(
       SUM ( 'Fact Ledger'[Ledger Balance] ),
       'd_balance_mappings'[Balance Type] = "Payments",
       TREATAS ( SelectedCollectionIDs, 'Fact Ledger'[Collection_ID] )
   )

RETURN
   BalancePart - PaymentPart

 

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

4 REPLIES 4
v-tsaipranay
Community Support
Community Support

Hi @HelloPBIWorld ,

Thank you for reaching out to the Microsoft fabric community forum.

 

Could you please confirm if the issue has been resolved. I wanted to check if you had the opportunity to review the information provided by @rohit1991 . Please feel free to contact us if you have any further questions.

 

Thank you.

rohit1991
Super User
Super User

Hi @HelloPBIWorld 


Since the relationships don’t allow filters to flow directly to the Fact Ledger (especially from d_balance_mappings), we can solve this using explicit filters inside the measure.

Measure:

daxCopyEditTotal Ledger Balance (Amicable) = 
VAR BalancePart =
    CALCULATE(
        SUM('f_fact_ledger'[Ledger Balance]),
        'd_balance_mappings'[Balance Type] IN {"Balance", "Costs"},
        'd_collection_types'[Collection type] = "Amicable"
    )
VAR PaymentPart =
    CALCULATE(
        SUM('f_fact_ledger'[Ledger Balance]),
        'd_balance_mappings'[Balance Type] = "Payments",
        'd_collection_types'[Collection type] = "Amicable"
    )
RETURN
    BalancePart - PaymentPart

rohit1991_0-1754558059244.jpeg

 

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

The  'd_collection_types'[Collection type] = "Amicable" is not filtering the measure even when I put it.

If you check the relationships I mentioned you can see that Dim Account is in between the 2 fact tables

Hi @HelloPBIWorld 

 

Option A (model fix – best for long term)

Add the Collection_Type_id to the fact (via PQ merge) or create a proper dim that’s on a single filter path to Fact Ledger:
d_collection_types >> f_collections >> Fact Ledger with filters flowing downstream. Then your original measure will work without tricks.

 

Option B (keep model – enforce filter in DAX with TREATAS)

Push the selected collection IDs onto the fact using TREATAS:

 

Total Ledger Balance (by Type) =
VAR SelectedCollectionIDs =
   CALCULATETABLE(
       VALUES ( 'f_collections'[Collection_ID] ),
       // use this if you want slicer-driven type
       KEEPFILTERS ( VALUES ( 'd_collection_types'[Collection type] ) )
       // or hard-code to Amicable:
       // 'd_collection_types'[Collection type] = "Amicable"
   )
VAR BalancePart =
   CALCULATE(
       SUM ( 'Fact Ledger'[Ledger Balance] ),
       'd_balance_mappings'[Balance Type] IN { "Balance", "Costs" },
      TREATAS ( SelectedCollectionIDs, 'Fact Ledger'[Collection_ID] )
   )
VAR PaymentPart =
   CALCULATE(
       SUM ( 'Fact Ledger'[Ledger Balance] ),
       'd_balance_mappings'[Balance Type] = "Payments",
       TREATAS ( SelectedCollectionIDs, 'Fact Ledger'[Collection_ID] )
   )

RETURN
   BalancePart - PaymentPart

 

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors