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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
vic_cin
New Member

Cumulative sum to-date minus cumulative sum up to last moth, the subtotal not correct

Hi all, 

 

Would like to get help in the following DAX measures. I would like to have the measure for number 3 to be able to showed as per the 4th column. 

 

1. I have created a sales GDV cumulative
2 Then created a sales GDV cumulative_last mth
3. When (1) - (2) = test_GDV_CM-LM  , I cannot get the results that I would like to have, as per the 4th column below. 

 

Measures

1. 

Sales GDV_Cumulative =
VAR _maxDate = MAX('Fact_Direct Cost POC reallocate'[Construction period])
VAR _ver = SELECTEDVALUE('Version'[Version])
RETURN
    CALCULATE(
        [Sales GDV_Total],
        'Version'[Version]=_ver,
        FILTER(
            ALL(Dim_Date),
            Dim_Date[Date] <= _MaxDate
        )
    )

2. 
Sales GDV_Cumulative_Last Mth =
VAR _maxDate = MAX('Fact_Direct Cost POC reallocate'[Construction period])
VAR _ver = SELECTEDVALUE('Version'[Version])
RETURN
    CALCULATE(
        [Sales GDV_Last Mth],
        'Version'[Version]=_ver,
        FILTER(
            ALLSELECTED(Dim_Date),
            Dim_Date[Date] <= _MaxDate
        )
    )
 
3. 
Test_GDV_CM-LM =
[Sales GDV_Cumulative]-[Sales GDV_Cumulative_Last Mth]
 
 
vic_cin_0-1707723132441.png

 

 



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @vic_cin ,

I created some data:

vyangliumsft_0-1707792636512.png

Measure follows the context of the "Total" row and is calculated in that context. Therefore, using a measure in a column of a table visualization may have unexpected values in the "Total" column.

 

You can use the following measure, using the IF()+ISINSCOPE() function, to determine if the specified level is the one, and if it is, then you can do the calculations according to your own needs, such as Average, Sum, etc. .

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _last=
    SUMX(        FILTER(ALL('Table'),'Table'[Group1]=MAX('Table'[Group1])&&'Table'[Group2]=MAX('Table'[Group2])&&'Table'[Group3]=MAX('Table'[Group3])-1),[Sales GDV_Cumulative])
var _current=
    SUMX(
            FILTER('Table','Table'[Group3]=MAX('Table'[Group3])),[Sales GDV_Cumulative])
return
IF(
    ISINSCOPE('Table'[Group3])&&NOT(ISINSCOPE('Table'[Group4])),
   _current - _last
    ,[Test_GDV_CM-LM])

2. Result:

vyangliumsft_1-1707792636517.png

 

Best Regards,

Liu Yang

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

1 REPLY 1
Anonymous
Not applicable

Hi  @vic_cin ,

I created some data:

vyangliumsft_0-1707792636512.png

Measure follows the context of the "Total" row and is calculated in that context. Therefore, using a measure in a column of a table visualization may have unexpected values in the "Total" column.

 

You can use the following measure, using the IF()+ISINSCOPE() function, to determine if the specified level is the one, and if it is, then you can do the calculations according to your own needs, such as Average, Sum, etc. .

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _last=
    SUMX(        FILTER(ALL('Table'),'Table'[Group1]=MAX('Table'[Group1])&&'Table'[Group2]=MAX('Table'[Group2])&&'Table'[Group3]=MAX('Table'[Group3])-1),[Sales GDV_Cumulative])
var _current=
    SUMX(
            FILTER('Table','Table'[Group3]=MAX('Table'[Group3])),[Sales GDV_Cumulative])
return
IF(
    ISINSCOPE('Table'[Group3])&&NOT(ISINSCOPE('Table'[Group4])),
   _current - _last
    ,[Test_GDV_CM-LM])

2. Result:

vyangliumsft_1-1707792636517.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.