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
setis
Post Partisan
Post Partisan

Filtering a running total

Dear experts, 

 

I need to calculate a running total with a date filter based on another column in the same table. 

 

I have a Calendar table with a relationship to the column "Posting date" in the table Sales Invoice Line.

 

The running total measure that works fine is:

 

 

Invoiced_RT= 
CALCULATE(
    SUM('Sales Invoice Line'[Amount]);
    FILTER(
        ALL(Calendar[Date]);
        Calendar[Date] <= MAX(Calendar[Date])))

 

 

 

In Sales Invoice Line there is a column called "Date closed".

 

I need to present the results on a Table/Matrix with the months in the rows. 

I need to filter the results from the measure above so it shows only the values that have a "Date closed" later than the End of the Month or "Date closed" = BLANK.

 

I have created a Column in my Calendar table called EOM that gives me the last day of the respective month.

 

I've been trying the following:

 

 

 

Invoiced_RT(Date open) = 
CALCULATE([Invoiced_RT] ; 
FILTER('Sales Invoice Line';
'Sales Invoice Line'[Date closed] > MAX(Calendar[EOM]) ||
'Sales Invoice Line'[Date closed] = BLANK()))

 

 

 

My problem is that I have an invoice with posting date in December 2019 that was closed in February 2020.

This invoice amount is showing up in December 2019 but not in January 2020 (it should be in both months).  

 

I hope that the question makes sense and it has an easy solution. If not, I'll try to produce a dummy report to show the issue. 

 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @setis,

I hope this works and pardon if there's any syntax error:
Exclude Measure =
CALCULATE (
SUM ( 'Sales Invoice Line'[Amount] ),
FILTER ( ALL ( Calendar ), Calendar[Date] <= MAX ( Calendar[Date] ) ),
FILTER (
ALL ( 'Sales Invoice Line'[PostingDate] ),
'Sales Invoice Line'[PostingDate]
> MAX ( Calendar[Date) || ISBLANK( 'Sales Invoice Line'[PostingDate] )
)
)









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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @setis,

I hope this works and pardon if there's any syntax error:
Exclude Measure =
CALCULATE (
SUM ( 'Sales Invoice Line'[Amount] ),
FILTER ( ALL ( Calendar ), Calendar[Date] <= MAX ( Calendar[Date] ) ),
FILTER (
ALL ( 'Sales Invoice Line'[PostingDate] ),
'Sales Invoice Line'[PostingDate]
> MAX ( Calendar[Date) || ISBLANK( 'Sales Invoice Line'[PostingDate] )
)
)









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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian It works. Thank you very much!

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.