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
marine_adz
Regular Visitor

Cumulative measure with both active and inactive relationships in use

I'm having trouble creating a cumulative sum with both direct and indirect relationships in play.  Simplified data structure is as shown - direct relationships between DateTable<-->Invoices and Invoices <--> Payments, then an inactive relationship between Payments <--> DateTable

 

Tables.png

 

I have a report level filter on InvoiceDate, to only show data for invoices issued within a certain period (in this case, year), then a matrix of payments per period. This uses the following measure, which works as intended:

 

Payments = CALCULATE(SUM([Payment Amount]),USERELATIONSHIP(DateTable[Date],Payments[PaymentDate]))

 

However, I can't figure out the cumulative total - I've tried the following. I've seen suggestions to nest CALCULATE statements, which I think the [Payments] measure is already doing, but I've also copied that calculation in place of the measure, to no effect.

 

Cumulative Payments = CALCULATE([Payments],FILTER(ALLSELECTED(DateTable),DateTable[Date]<=MAX(DateTable[Date])))

 

Cumulative Payments = CALCULATE([Payments],FILTER(ALLSELECTED(DateTable),DateTable[Date]<=MAX(DateTable[Date])),USERELATIONSHIP(DateTable[Date],Invoices[InvoiceDate]))

 

Cumulative Payments = CALCULATE(CALCULATE(SUM([Payment Amount]),USERELATIONSHIP(DateTable[Date],Payments[PaymentDate])),FILTER(ALLSELECTED(DateTable),DateTable[Date]<=MAX(DateTable[Date])),USERELATIONSHIP(DateTable[Date],Invoices[InvoiceDate]))

 

Any ideas gratefully received!

2 ACCEPTED SOLUTIONS
ValtteriN
Super User
Super User

Hi,

I think by removing the FILTER in your first cumulative calculation there shouldn't be any issues. If there are try using CROSSFILTER to make sure there isn't any cyclic references.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Thanks for replying - without the filter, isn't it just the original measure without being cumulative?

 

I'm sure there will be a way around this through DAX, but I managed to solve it much more simply - created another table (DateTablePayment = 'DateTable'), removed the inactive relationship and added a new active relationship between Payments[PaymentDate] and DateTablePayment[Date]

View solution in original post

3 REPLIES 3
ValtteriN
Super User
Super User

Hi,

I think by removing the FILTER in your first cumulative calculation there shouldn't be any issues. If there are try using CROSSFILTER to make sure there isn't any cyclic references.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for replying - without the filter, isn't it just the original measure without being cumulative?

 

I'm sure there will be a way around this through DAX, but I managed to solve it much more simply - created another table (DateTablePayment = 'DateTable'), removed the inactive relationship and added a new active relationship between Payments[PaymentDate] and DateTablePayment[Date]

Hi @marine_adz 

I meant removing the FILTER and its corresponding () signs. The basic pattern for RT calculation is like this:
var maxdate = MAX('Calendar'[Date])
CALCULATE(SUM(Table[Value]),ALL(Calendar),Calendar[Date]<=maxdate) 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

Top Solution Authors