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

View all the Fabric Data Days sessions on demand. View schedule

Reply
ddbaker
Helper I
Helper I

Measure totals not summing correctly

Hi everyone,

 

Here is my current measure. Basically what it's doing is checking to see if a customer has any future invoices and holds the revenue amount equal to the previous invoice amount. 

 

Monthly ARR = 
VAR LastInvoice =
    CALCULATE(
        MAX(Invoice[Invoice Date]),
        DATESBETWEEN(
            'Calendar'[Date],
            CALCULATE(
                MIN('Calendar'[Date]),
                ALL('Calendar')
            ),
            LASTDATE('Calendar'[Date])
        )
    )
VAR NextInvoice = 
    CALCULATE(
        MIN(Invoice[Invoice Date]),
        DATESBETWEEN(
            'Calendar'[Date],
            LASTDATE('Calendar'[Date]),
            CALCULATE(
                MAX('Calendar'[Date]),
                ALL('Calendar')
            )
        )
    )
RETURN
IF(
    CALCULATE(
        SUM(Invoice[ARR Amount]), 
        Invoice[Months]=1
    ) = 0,
    IF(
        CALCULATE(MAX(Invoice[Months]),DATESBETWEEN('Calendar'[Date], LastInvoice, LastInvoice))<>1,
        0,
        IF(LastInvoice = 0 || NextInvoice = 0,
            0,
            CALCULATE(
                SUM(Invoice[ARR Amount]),
                DATESBETWEEN(
                    'Calendar'[Date],
                    LastInvoice,
                    LastInvoice
                )
            )
        )
    ),
    CALCULATE(
        SUM(Invoice[ARR Amount]), 
        Invoice[Months]=1
    )
)

 

 This measure actually works perfectly for each customer. But the total doesn't sum correctly the values in each row. I've been researching how to work with the total row context, but I haven't been able to figure it out. Any thoughts?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I have not gone through your measure in detail, but if the measure returns the correct values at each customer level, but if only the total row is incorrect, then the easiest solution is to actually create another measure that adds the value of each customer using your current measure. Something like this..

 

New Measure =
VAR CustomerList = VALUES( < customer field> )
VAR Result = SUMX(CustomerList, Monthly ARR)
RETURN Result

Then, instead of the measure, "Monthly ARR", use this "New Measure" in your report visuals. What it does is the following....

 

1) Creates a temporary table with the list of customers (VALUES)

2) Iterate through this table and for each customer entry, it will calculate the "Monthly ARR" in the context of each customer, and then sums it up.

3) For each row, the VALUES is gonna return only one customer, but in the total, it will return all the customers in the current context. In either case, SUMX will give you the desired output.

 

Please try this out and see if it gives you the correct results. If not, do reply with more details.

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

I have not gone through your measure in detail, but if the measure returns the correct values at each customer level, but if only the total row is incorrect, then the easiest solution is to actually create another measure that adds the value of each customer using your current measure. Something like this..

 

New Measure =
VAR CustomerList = VALUES( < customer field> )
VAR Result = SUMX(CustomerList, Monthly ARR)
RETURN Result

Then, instead of the measure, "Monthly ARR", use this "New Measure" in your report visuals. What it does is the following....

 

1) Creates a temporary table with the list of customers (VALUES)

2) Iterate through this table and for each customer entry, it will calculate the "Monthly ARR" in the context of each customer, and then sums it up.

3) For each row, the VALUES is gonna return only one customer, but in the total, it will return all the customers in the current context. In either case, SUMX will give you the desired output.

 

Please try this out and see if it gives you the correct results. If not, do reply with more details.

 

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.

Top Solution Authors
Top Kudoed Authors