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
Roseventura
Responsive Resident
Responsive Resident

Need CUMULATIVE measure to reset by Fiscal Month

I need to show a Cumulative total in a Matrix table, but it keeps continuing the running total from month to month.  I need it to reset at the beginning of each Fiscal month.

 

My formulas:

 

Total Shipments TY = calculate([Total Shipments],filter(PBI_AEP_Shipments_B2B_Multi,year(PBI_AEP_Shipments_B2B_Multi[Transaction Date])=[Today Year]))

 

LastSalesDate = LASTNONBLANK( PBI_FSCAPF[PADDATE] , [Total Shipments] )

 

Cumulative Shipments TY =
IF(SELECTEDVALUE (PBI_FSCAPF[PADDATE])> [LastSalesDate], BLANK(),
CALCULATE( [Total Shipments TY] ,
FILTER( ALLSELECTED( PBI_FSCAPF),
PBI_FSCAPF[PADDATE] <= MAX( PBI_FSCAPF[PADDATE] ))))

 

The table is arranged by Calendar Day in Month (CADIM), so what I need is when February is shown, it display what the sales are for only Day 1 of February, and then accumulate from there. It’s picking up January’s sales.

 

Capture29.JPG

3 ACCEPTED SOLUTIONS
Anonymous
Not applicable

You need the counterpart of the MTD calculation but based on a fiscal calendar. Here's one way to do it:

 

// Please adjust the names accordingly.
// Bear in mind that this will only return
// non-BLANK if there is only one
// FiscalMonthNumber visible in the current
// context. This is due to the SELECTEDVALUE
// function that will return BLANK if there
// is more than 1 fiscal month visible. Cumulative MTD := // Dates is your calendar. var __minDateVisible = MIN ( 'Dates'[DateKey] ) var __maxDateVisible = MAX ( 'Dates'[DateKey] ) // FiscalMonthNumber is an integer that numbers // fiscal months from 1 up to the last one in // your Dates, consecutively. var __currentFiscalMonth = SELECTEDVALUE ( 'Dates'[FiscalMonthNumber] ) // Transactions is your fact table. var __lastTransactionDate = CALCULATE ( MAX ( Transactions[DateKey] ), ALL ( Transactions ) )
// Gets all the dates in the current fiscal
// month from the first day to the last
// visible in the current context. var __filter = filter ( all ( Dates ), 'Dates'[Date] <= __maxDateVisible && 'Dates'[FiscalMonthNumber] = __currentFiscalMonth ) var __cumulative = CALCULATE ( [Your Measure], __filter ) return // This IF is here to make sure // that the value is not calculated // in periods that start after the // very last transaction date. IF ( __minDateVisible <= __lastTransactionDate, __cumulative )

Best

Darek

View solution in original post

I will try this solution and get back to you.  (Sorry...was on vacation.)

 

Rose

 

View solution in original post

This solution worked perfected for me.

 

Thank you!!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

You need the counterpart of the MTD calculation but based on a fiscal calendar. Here's one way to do it:

 

// Please adjust the names accordingly.
// Bear in mind that this will only return
// non-BLANK if there is only one
// FiscalMonthNumber visible in the current
// context. This is due to the SELECTEDVALUE
// function that will return BLANK if there
// is more than 1 fiscal month visible. Cumulative MTD := // Dates is your calendar. var __minDateVisible = MIN ( 'Dates'[DateKey] ) var __maxDateVisible = MAX ( 'Dates'[DateKey] ) // FiscalMonthNumber is an integer that numbers // fiscal months from 1 up to the last one in // your Dates, consecutively. var __currentFiscalMonth = SELECTEDVALUE ( 'Dates'[FiscalMonthNumber] ) // Transactions is your fact table. var __lastTransactionDate = CALCULATE ( MAX ( Transactions[DateKey] ), ALL ( Transactions ) )
// Gets all the dates in the current fiscal
// month from the first day to the last
// visible in the current context. var __filter = filter ( all ( Dates ), 'Dates'[Date] <= __maxDateVisible && 'Dates'[FiscalMonthNumber] = __currentFiscalMonth ) var __cumulative = CALCULATE ( [Your Measure], __filter ) return // This IF is here to make sure // that the value is not calculated // in periods that start after the // very last transaction date. IF ( __minDateVisible <= __lastTransactionDate, __cumulative )

Best

Darek

I will try this solution and get back to you.  (Sorry...was on vacation.)

 

Rose

 

This solution worked perfected for me.

 

Thank you!!

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