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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
jrpallares89
New Member

Summarize Quick Measure Month-over-Month

Hi all,

 

I have a problem in the total row of a table, specifically, in the column "Margen Real--MoM2"

with the standard quick measure for month-over-month calculation.

The formula is:

 

Margen Real--MoM2 =
IF(
    ISFILTERED('Calendar'[Date]),
    ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
    VAR __PREV_MONTH =
        CALCULATE(
            SUM('ClosingSAP'[Margen Real--2022]),
            DATEADD('Calendar'[Date].[Date], -1, MONTH)
        )
    RETURN
            IF(__PREV_MONTH>SUM('ClosingSAP'[Margen Real--2022]),BLANK(),SUM('ClosingSAP'[Margen Real--2022]) - __PREV_MONTH)
)

And the expected value is 245.010,91€

 

jrpallares89_0-1651143640541.png

 

I suspect this is the reason because the other measure "Real+UPA" also summarize in a wrong way.

Thanks in advance for any help.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jrpallares89 ,

Please try to update the formula of measure [Margen Real--MoM2] as below and check whether it can return the correct result.

Margen Real--MoM2 =
VAR _selyear =
    SELECTEDVALUE ( 'Calendar'[Date].[Year] )
VAR _selmonth =
    SELECTEDVALUE ( 'Calendar'[Date].[MonthNo] )
VAR _preldate =
    DATE ( _selyear, _selmonth, 1 ) - 1
VAR __PREV_MONTH =
    CALCULATE (
        SUM ( 'ClosingSAP'[Margen Real--2022] ),
        FILTER (
            ALLSELECTED ( 'ClosingSAP' ),
            YEAR ( 'ClosingSAP'[Date] ) = YEAR ( _preldate )
                && MONTH ( 'ClosingSAP'[Date] ) = MONTH ( _preldate )
        )
    )
RETURN
    IF (
        __PREV_MONTH > SUM ( 'ClosingSAP'[Margen Real--2022] ),
        BLANK (),
        SUM ( 'ClosingSAP'[Margen Real--2022] ) - __PREV_MONTH
    )

If the above one can't help you get the desired result, please provide some sample data in your table ClosingSAP (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @jrpallares89 ,

Please try to update the formula of measure [Margen Real--MoM2] as below and check whether it can return the correct result.

Margen Real--MoM2 =
VAR _selyear =
    SELECTEDVALUE ( 'Calendar'[Date].[Year] )
VAR _selmonth =
    SELECTEDVALUE ( 'Calendar'[Date].[MonthNo] )
VAR _preldate =
    DATE ( _selyear, _selmonth, 1 ) - 1
VAR __PREV_MONTH =
    CALCULATE (
        SUM ( 'ClosingSAP'[Margen Real--2022] ),
        FILTER (
            ALLSELECTED ( 'ClosingSAP' ),
            YEAR ( 'ClosingSAP'[Date] ) = YEAR ( _preldate )
                && MONTH ( 'ClosingSAP'[Date] ) = MONTH ( _preldate )
        )
    )
RETURN
    IF (
        __PREV_MONTH > SUM ( 'ClosingSAP'[Margen Real--2022] ),
        BLANK (),
        SUM ( 'ClosingSAP'[Margen Real--2022] ) - __PREV_MONTH
    )

If the above one can't help you get the desired result, please provide some sample data in your table ClosingSAP (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Thanks a lot!

It works!

jrpallares89
New Member

PS: I renamed the column for the visual to "Real GM MoM"

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors