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
ghunt03
Frequent Visitor

Calculating the last non blank value not totaling correctly

I am trying to get the last non blank value from a table of entries by month. The issue I am having is I can't get the grand total to work correctly 

 

Estimated Cost @@ Completion - Last Reported = 
var minDate = MIN('Calendar'[Date])
var totalCost = CALCULATE (
    (SUM ( 'Work In Progress'[Cost] ) + SUM('Work In Progress'[CostAdjustment])),
    LASTNONBLANK ( FILTER(ALL(Calendar[Date]), 'Calendar'[Date] <= minDate), CALCULATE ( SUM ( 'Work In Progress'[Cost] ) +  SUM ( 'Work In Progress'[CostAdjustment] ) ) )
)

return totalCost

Screen Shot 2018-05-30 at 8.11.31 pm.png

I am using the minimum date because I am trying to calculate the last reported value for the selected period.

 

Screen Shot 2018-05-30 at 8.19.46 pm.png

 

Any help would be greatly appreciated

3 REPLIES 3
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @ghunt03,

 

Can you share the file? Please mask the private parts first.

Why did you use LASTNONBLANK?

Maybe the formula could work.

Estimated Cost @@ Completion - Last Reported = 
var minDate = MIN('Calendar'[Date])
var totalCost = 
    LASTNONBLANK ( FILTER(ALL(Calendar[Date]), 'Calendar'[Date] <= minDate), SUM ( 'Work In Progress'[Cost] ) +  SUM ( 'Work In Progress'[CostAdjustment] ) 
)

return totalCost

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.

Hi @v-jiascu-msft

 

I was using the LASTNONBLANK formula to find the latest reported value. The formula you suggested only seems to return a date

 

I have a copy of the file available at the following link

 

Example File

 

The other option I have tried is to lookup the Cost and Cost Adjusment value as there is only a maximum of one entry per month.  However I haven't been able to figure out the correct syntax for this one either

Hi @ghunt03,

 

I wonder if the solution below could help.

1. Create a new table "Contract" due to not all the contract exists in all the months.

Contract = DISTINCT(VALUES('Work In Progress'[Contract]))

2. Create a calculated table.

Result =
SUMMARIZECOLUMNS (
    Contract[Contract],
    'Work In Progress'[Mth],
    "value",
    VAR total =
        SUM ( 'Work In Progress'[Cost] ) + SUM ( 'Work In Progress'[CostAdjustment] )
    RETURN
        IF (
            ISBLANK ( total ),
            CALCULATE (
                (
                    SUM ( 'Work In Progress'[Cost] ) + SUM ( 'Work In Progress'[CostAdjustment] )
                ),
                LASTNONBLANK (
                    FILTER ( ALL ( 'Work In Progress'[Mth] ), 'Work In Progress'[Mth] <= [Mth] ),
                    CALCULATE (
                        SUM ( 'Work In Progress'[Cost] ) + SUM ( 'Work In Progress'[CostAdjustment] )
                    )
                )
            ),
            total
        )
)

3. Create a visual based on the new table.

Calculating_the_last_non_blank_value_not_totaling_correctly

 

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.

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