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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Filter two fact table date columns with single date dimension table and inactive relationships

A fact table contains accumulated daily snapshots of term deposit data from a bank system. I want to calculate the amount that will have matured on future dates given maturity information as of the most recent snapshot date.

I have a single 'Calendar' date dimension table that has inactive relationships to (among others) both 'Deposits'[Snapshot Date] and 'Deposits'[Maturity Date].

USERELATIONSHIP('Deposits[Maturity Date], 'Calendar'[Date]) allows me to plot maturity amounts along 'Calendar'[Date], but I don't know how to most efficiently apply a single date filter to 'Deposits'[Snapshot Date].

 

I could duplicate 'Calendar' as the Role-Playing 'Calendar (Snapshot Date)' table, define an active relationship, and apply a filter like 'Calendar (Snapshot Date)'[Date] = '2023-02-05' to my model.

The downside is the engine must scan the addtional date table and transfer the filter.

 

Alternatively, I could just apply the Snapshot date filter directly to the fact table, as in 'Deposits'[Snapshot Date] = '2023-02-05'. That would make the engine inefficiently scan the still very large subset of fact table rows where Maturity Date = 'Calendar'[Date].

 

I know two relationships cannot be active between two tables at the same time but are there any tricks that permit a better way to do this?

 

The fact table will quickly grow to 100's of millions of rows, so I'm looking for the most efficient implementation possible.

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , First create meausre with use relationship

 

m1= calculate( SUM(Table[Amount]),USERELATIONSHIP ('Table'[Maturity Date], 'Calendar'[Date]))

 

m2= calculate( SUM(Table[Amount]),USERELATIONSHIP ('Table'[Snapshot Date], 'Calendar'[Date]))

 

Then create cumulative measures

 

examples

Cumm Sales = CALCULATE([M1],filter(all('Calendar'),'Calendar'[date] <=max('Calendar'[date])))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.