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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
deasons22
Helper II
Helper II

Rolling sum with a single month selected in slicer

I'm looking to get a 12 month Sum based on a single month selection in  a slicer. I have a formula that is totaling correctly, but only when i select at least a year+ worth of months. Ideally this will default to opening in the current month, so i would like to get a total of the 12 months prior.

 

Thanks,

Sam

1 ACCEPTED SOLUTION

Hi @deasons22,

 

Since you said the formula works fine, I would suggest you change the blue part like below.

Current Customer Growth Count rolling average =
IF (
    ISFILTERED ( 'Dim_Date'[PK_Date] ),
    ERROR ( "Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column." ),
    VAR __LAST_DATE =
        IF (
            ISBLANK ( SELECTEDVALUE ( 'Dim_Date'[PK_Date] ) ),
            ENDOFMONTH ( 'Dim_Date'[PK_Date].[Date] ),
            EOMONTH ( SELECTEDVALUE ( 'Dim_Date'[PK_Date] ), 0 )
        )
    VAR __DATE_PERIOD =
        DATESBETWEEN (
            'Dim_Date'[PK_Date].[Date],
            STARTOFMONTH ( DATEADD ( __LAST_DATE, -12, MONTH ) ),
            __LAST_DATE
        )
    RETURN
        SUMX (
            CALCULATETABLE (
                SUMMARIZE (
                    VALUES ( 'Dim_Date' ),
                    'Dim_Date'[PK_Date].[Year],
                    'Dim_Date'[PK_Date].[QuarterNo],
                    'Dim_Date'[PK_Date].[Quarter],
                    'Dim_Date'[PK_Date].[MonthNo],
                    'Dim_Date'[PK_Date].[Month]
                ),
                __DATE_PERIOD
            ),
            CALCULATE ( [Current Customer Growth Count], ALL ( 'Dim_Date'[PK_Date].[Day] ) )
        )
)

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @deasons22,

 

Could you please mark the proper answers as solutions?

 

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
shebr
Resolver III
Resolver III

Hi @deasons22

 

Could you share your code for the measure you have created, or perhaps the pbix file? It could be that your measure needs some additional functions adding to it such as the ALL function. This allows tables/columns to be ignored when filtering.

 

Thanks

 

shebr

Hi Shebr,

 

Here's what i'm currently using. 

 

Current Customer Growth Count rolling average =
IF(
ISFILTERED('Dim_Date'[PK_Date]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
VAR __LAST_DATE = ENDOFMONTH('Dim_Date'[PK_Date].[Date])
VAR __DATE_PERIOD =
DATESBETWEEN(
'Dim_Date'[PK_Date].[Date],
STARTOFMONTH(DATEADD(__LAST_DATE, -12, MONTH)),
__LAST_DATE
)
RETURN
SUMX(
CALCULATETABLE(
SUMMARIZE(
VALUES('Dim_Date'),
'Dim_Date'[PK_Date].[Year],
'Dim_Date'[PK_Date].[QuarterNo],
'Dim_Date'[PK_Date].[Quarter],
'Dim_Date'[PK_Date].[MonthNo],
'Dim_Date'[PK_Date].[Month]
),
__DATE_PERIOD
),
CALCULATE([Current Customer Growth Count], ALL('Dim_Date'[PK_Date].[Day]))
)
)

Hi @deasons22,

 

Since you said the formula works fine, I would suggest you change the blue part like below.

Current Customer Growth Count rolling average =
IF (
    ISFILTERED ( 'Dim_Date'[PK_Date] ),
    ERROR ( "Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column." ),
    VAR __LAST_DATE =
        IF (
            ISBLANK ( SELECTEDVALUE ( 'Dim_Date'[PK_Date] ) ),
            ENDOFMONTH ( 'Dim_Date'[PK_Date].[Date] ),
            EOMONTH ( SELECTEDVALUE ( 'Dim_Date'[PK_Date] ), 0 )
        )
    VAR __DATE_PERIOD =
        DATESBETWEEN (
            'Dim_Date'[PK_Date].[Date],
            STARTOFMONTH ( DATEADD ( __LAST_DATE, -12, MONTH ) ),
            __LAST_DATE
        )
    RETURN
        SUMX (
            CALCULATETABLE (
                SUMMARIZE (
                    VALUES ( 'Dim_Date' ),
                    'Dim_Date'[PK_Date].[Year],
                    'Dim_Date'[PK_Date].[QuarterNo],
                    'Dim_Date'[PK_Date].[Quarter],
                    'Dim_Date'[PK_Date].[MonthNo],
                    'Dim_Date'[PK_Date].[Month]
                ),
                __DATE_PERIOD
            ),
            CALCULATE ( [Current Customer Growth Count], ALL ( 'Dim_Date'[PK_Date].[Day] ) )
        )
)

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks I'll give that a shot. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.